PHP Form Validation.

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jul 20th, 2006, 18:56
kaz kaz is offline
Up'n'Coming Member
Join Date: Feb 2005
Location: Accra
Age: 42
Posts: 54
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to kaz
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">&nbsp;</td>
</tr>
</form>
</table>
</body>
</html>
?>

thanx
Reply With Quote

  #2 (permalink)  
Old Jul 21st, 2006, 17:00
Up'n'Coming Member
Join Date: Jan 2006
Location: East Sussex
Age: 26
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #3 (permalink)  
Old Jul 22nd, 2006, 20:47
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: PHP Form Validation.

Your synatx of the include function is not correct either.
Code: Select all
include ('config.php');
Note the round brackets.

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:
Change the name of the input submit field to submit instead of send and it should work
Or of course check for
Code: Select all
isset($_POST['send']);
Reply With Quote
Reply

Tags
php, form, validation

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 22:27.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43