4WebHelp
 FAQ  •  Search  •  User Groups  •  Forum Admins  •  Smilies List  •  Statistics  •  Rules   •  Login   •  Register
Toggle Navigation Menu

 cannot check the data provided by a form
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic
Author Message
scifo
Junior WebHelper
Junior WebHelper


Joined: 27 Jul 2003
Posts: 4

PostPosted: Wed Aug 06, 2003 1:55 pm (14 years, 2 months ago) Reply with QuoteBack to Top

I have a file which processes the data submitted by the form. I want to check whether the data submitted is identical to the data in mysql database so that if it is not the user corrects the form and submits it again. Here is the code which cannot check the data in submitted form:

Code:
<?php
global $HTTP_POST_VARS;
if (isset($HTTP_POST_VARS['mybutton'])) {
$Host = "***";
$DBName = "***";
$TableName = "patientsform";
$Link = mysql_connect ($Host, '***', '***');
if ($Link==false) {
echo mysql_errno().": ".mysql_error()."<BR>\n";
}
mysql_select_db ($DBName, $Link);
$Query1 = "SELECT Forename FROM patients WHERE Forename = {$HTTP_POST_VARS['forename']} AND Surname = {$HTTP_POST_VARS['surname']}";
//The query to check the data submitted
$Query = "INSERT INTO $TableName VALUES ('0', '{$HTTP_POST_VARS['forename']}')";
//The query to put the submitted data into the table

if (mysql_query ($Query1, $Link)) {
print "The query1 was successfully executed!<BR>\n";

if (mysql_query ($Query, $Link)) {
print "The query was successfully executed!<BR>\n";
}
else {
print "The query could not be executed!<BR>\n";
echo mysql_errno().": ".mysql_error()."<BR>\n";
}

}
else {
print "The query1 could not be executed!<BR>\n";
echo mysql_errno().": ".mysql_error()."<BR>\n";
}

mysql_close($Link);
} //end of isset function

else {
echo "you must have come here from somewhere else.\n";
}


MEG
OfflineView User's ProfileFind all posts by scifoSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Wed Aug 06, 2003 3:18 pm (14 years, 2 months ago) Reply with QuoteBack to Top

Where abouts is the script failing?
any error messages?
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
scifo
Junior WebHelper
Junior WebHelper


Joined: 27 Jul 2003
Posts: 4

PostPosted: Wed Aug 06, 2003 3:25 pm (14 years, 2 months ago) Reply with QuoteBack to Top

When i submit the form by writing 'Martin' in the forename area i get this error message
The query1 could not be executed!
1054: Unknown colomn 'Martin' in 'where clause'

Nevertheless, I know that there are 2 rows with the value of Martin in forename field.
????
OfflineView User's ProfileFind all posts by scifoSend Personal Message
Darren
Team Member



Joined: 05 Feb 2002
Posts: 549
Location: London

PostPosted: Wed Aug 06, 2003 4:27 pm (14 years, 2 months ago) Reply with QuoteBack to Top

try putting the forename and surname variables in single quotes
OfflineView User's ProfileFind all posts by DarrenSend Personal MessageVisit Poster's Website
Display posts from previous:      
Post New TopicReply to Topic
View Previous Topic Print this topic View Next Topic


 Jump to:   




You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot edit your posts in this forum.
You cannot delete your posts in this forum.
You cannot vote in polls in this forum.


Page generation time: 0.071034 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0 © 2001, 2002 phpBB Group :: Based on an FI Theme