This is a discussion on "PHP Form Validation." within the PHP Forum section. This forum, and the thread "PHP Form Validation. are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
PHP Form Validation.
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
PHP Form Validation.
I'm doin a Web Programming Course and we were asked to do a simple contact for. for some reason it's not running. Can someone tell me why?
here is the code: <?php IF(ISSET($_POST['submit'])){ $NAME = $_POST ['name']; $EMAIL = $_POST ['email']; $SUBJECT = $_POST ['_subject']; $MESSAGE = $_POST ['message']; include 'config.php'; include 'opendb.php'; $result = mysql_query($query); ELSE { ECHO $Name; ECHO $EMAIL; ECHO $SUBJECT; ECHO $MESSAGE; } mysql_connect($dbhost, $dbuser, $dbpass) or die('cannot select database'); ?> <html> <head> <title>Personal Information</title> </head> <body> <table width="650" border="0" align="center" cellspacing="0"> <tr> <form method="post" name="msgform"> <table width="500" border="0" align="center" cellpadding="2" cellspacing="1"> <tr> <td width="106">Your Name</td> <td width="381"><input name="name" type="text" class="box" id="name" size="30" value=""></td> </tr> <tr> <td>Your Email</td> <td><input name="email" type="text" id="mail" size="30" value=""></td> </tr> <tr> <td>Subject</td> <td><input name="subject" type="text" id="subject" size="30" value=""></td> </tr> <tr> <td>Message</td> <td><textarea name="message" cols="55" id="message"></textarea></td> </tr> <tr align="center"> <td colspan="2"><input name="send" type="submit" id="send" value="Send Message" onClick="return checkForm();"></td> </tr> <tr align="center"> <td colspan="2"> </td> </tr> </form> </table> </body> </html> ?> thanx |
|
|
|
|||
|
Re: PHP Form Validation.
You dont have a } in your if statment,
if(statement){ code }else{ code } but do you really need this else statement? Cant see why you would, if you do you should also set the variables with a value. also you dont need the ?> at the end of the document and you dont have a post variable called submit. Change the name of the input submit field to submit instead of send and it should work |
|
|||
|
Re: PHP Form Validation.
Your synatx of the include function is not correct either.
Have no way of knowing what the code in the two includ files is doing but the flow of the code looks a bit odd. You seem to be trying to run a query before you have conected to the database. Quote:
|
![]() |
| Tags |
| php, form, validation |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Form validation help! | psycho wolvesbane | JavaScript Forum | 16 | Feb 12th, 2008 16:40 |
| AS Form / Validation Help | papalazarou78 | Flash & Multimedia Forum | 0 | Jul 31st, 2007 19:43 |
| Form Validation | cjrollo | Flash & Multimedia Forum | 0 | Feb 22nd, 2007 17:33 |
| Form Validation | feebee | JavaScript Forum | 1 | Aug 3rd, 2006 16:12 |
| PHP Form Validation ??? | j4mes_bond25 | PHP Forum | 2 | May 31st, 2006 23:08 |