Jump to content

[SOLVED] php validation


ilikephp

Recommended Posts

hi,

when these fields are checked, I want the submit button to open the response.php page.

if it contains errors they will be fixed and if no response.php will open when clicked on it.

is it possible to do it?

 

Thanks...

I put this code, but it is wrong :S

 
<?php 
if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept']) ){
}?>
<input name="submit" type="submit" onClick="document.contactForm.action='response.php';" value="Submit">

Link to comment
https://forums.phpfreaks.com/topic/158742-solved-php-validation/
Share on other sites

hi,

when these fields are checked, I want the submit button to open the response.php page.

if it contains errors they will be fixed and if no response.php will open when clicked on it.

is it possible to do it?

 

Thanks...

I put this code, but it is wrong :S

 
<?php 
if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept']) ){
}?>
<input name="submit" type="submit" onClick="document.contactForm.action='response.php';" value="Submit">

 

Huh?

Well, it's possible and not possible. First though, your code would better be off with

<?php 
if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept']))
   {
echo ("<input name=\"submit\" type=\"submit\" onClick=\"document.contactForm.action='response.php';\" value=\"Submit\">");
   } ?>

The problem with your existing code was that it didn't pass anything through the brackets, which are the "then" part of "if..then..else". However, if you want it to update every moment, (this script only changes on page refresh, which might still break the script) then you should try Javascript.

thanks a lot, I fixed it.

but the only problem that I still have is when I enter all the information, the submit button will appear, and the fieds are becoming empty, how can I keep the information inside the fields?

 

<input type="text" name="name_of" value="<?PHP echo htmlspecialchars($_POST['name_of']); ?>">

You can combine this line -

if (!isset($error['name']) && !isset($error['email']) && !isset($error['password']) && !isset($error['accept']))

 

into -

if (!isset($error['name'], $error['email'], $error['password'], $error['accept']))

 

What the OP posted and what you have here are, logically, not the same. Passing multiple variables to isset (joined by commas) checks them all with respect to OR; that is, if any one of the 4 variables passed in here isn't set, the entire statement will return true (because of the logical NOT; isset will return false).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.