PDA

View Full Version : Field Validation


Saj
05-01-2003, 07:42 PM
OK, I'm just checking if the fields are not empty, and this doesn't seem to be working....I'm a newb to php so I'm sure its just a very simple error.

here is board.php


<form action="addmsg.php" method="post" name="message">
<input type="text" size="53" maxlength="19" name="name" />
<input type="text" size="53" maxlength="19" name="email" />
<textarea cols="40" rows="6" name="msg"></textarea>
<input type="submit" id="submit" value="Submit" name="submit" />
</form>


and addmsg.php


<?php
if (!$name || !$email || !$msg) {
header("Location: board.php?error");
}
else {
echo "Success!";
}
?>


Thanks

Nightfire
05-01-2003, 08:13 PM
<?php
if (empty($_POST)) {
header("Location: board.php?error");
}
else {
echo "Success!";
}
?>


Give that a shot, might work

Saj
05-04-2003, 04:14 PM
Actually, that doesn't seem to work.

Also, can you please tell me what I am doing wrong here?

I have the same form, and I am submitting from board.php to addmsg.php. For some reason, I cannot print the variables that have been submitted.

If the name field has the vaile Bob, then the url is http://url/addmsg.php?name=Bob

I am running this from my local server, and I have no trouble with printing other variables...here's what the code is:


echo "Hello <b>$user</b> \n\n You want to talk about <b>". $subject ."</b>";


Thanks for your help.