values not being entered into table
Posted on
16th Feb 2014 07:03 pm by
admin
hi. I;ve created a form, so that when a user enters data into it, it gets added to a table in a database. the form submits some data to one table, and other data to another table. my problem is that the data only gets added to the first table, but data doesnt enter correnctly into the other one.
Code: <?PHP
$questionno = $_POST['questionno'];
$question = $_POST['question'];
$quizref = $_POST['quizref'];
$answerno = $_POST['answerno'];
$answer = $_POST['answer'];
$answervalue = $_POST['answervalue'];
pg_connect("host=database.*******.uk
port=5432 dbname=***** user=***** password=******");
?>
<html>
<head>
<title>Add </title>
</head>
<body>
<?php
$query="INSERT INTO questions (questionno, question, quizref)VALUES ('".$questionno."', '".$question."', '".$quizref."')";
pg_query($query) or die ('Error adding new question');
echo "The question has been added to the quiz";
$queryanswers="INSERT INTO answers (answerno, answer, answervalue, questionno, quizref)VALUES ('".$answerno."', '".$answer."','".$answervalue."', '".$questionno."', '".$quizref."')";
pg_query($queryanswers) or die ('Error adding new answers');
echo "The answers has been added to the question";
?>
<form method="post" action="">
quizref: <br/>
<input type="text" name ="quizref" size="5" /><br/>
Question Number: <br/>
<input type="text" name="questionno" size="5" /><br/>
Question: <br/>
<input type="text" name="question" size="60" /><br/>
Answers<br/><br/>
Answer number:<br/>
<input type="text" name ="answerno" size="5" /><br/>
Answer<br/>
<input type="text" name ="answer" size="60" /><br/>
Answer value<br/>
<input type="text" name ="answervalue" size="5" /><br/>
<br/><br/>
Answer number:<br/>
<input type="text" name ="answerno" size="5" /><br/>
Answer<br/>
<input type="text" name ="answer" size="60" /><br/>
Answer value<br/>
<input type="text" name ="answervalue" size="5" /><br/>
<br/><br/>
Answer number:<br/>
<input type="text" name ="answerno" size="5" /><br/>
Answer<br/>
<input type="text" name ="answer" size="60" /><br/>
Answer value<br/>
<input type="text" name ="answervalue" size="5" /><br/>
<br/><br/>
Answer number:<br/>
<input type="text" name ="answerno" size="5" /><br/>
Answer<br/>
<input type="text" name ="answer" size="60" /><br/>
Answer value<br/>
<input type="text" name ="answervalue" size="5" /><br/>
<br/><br/>
<input type="submit" value="Send and Add another Add Questions" />
<a href="addfinish.php"><input type="submit" value="Add and finish" /></a>
</form>
</body>
</html>
Any help would be great.
thanks
No comments posted yet
Your Answer:
Login to answer
315
28
Other forums
Internal class functions don't seem to get executed.
Hi. Can someone please put me out of my misery on this. I don't write much PHP and this has me baffl
PHP loop
Okay so I have several "articles" stored in a mysql database and am attempting to echo tho
Why does first ever HttpSendRequest take longer?
I promise this isn't as simple as it sounds. I'm wondering why the the first ever call to HttpSendRe
php - xml what is the best way to do this.
IN essence I want to have a script calling the info from the database.. I have no problem thus far,
FILTER_CALLBACK -- Files?
Hi All,
I'm using the php filter functions to validate my form data. For custom filters, I'm
PHP webpage & array print issue
I have this code running, and it works perfectly … however, see my bottom bit about what I see
PHP Display Telephone Number On Referrer
I have used the php below to show a different telephone number in the header of the site depending u
XML Grouping
I'm using xml_parse_into_struct to get all my elements, but now I need to group them. For example, h
JSON SORT WITH PHP
I have two products that I want to sort by say "Id:17, value: xxx" using php
The page w
how to configure ADS in ABAP instance
Hi All,
I am working on r/3 4.7 ABAP system.Can we configure ADS(adobe document services)