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
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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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']); ?>">

Link to comment
Share on other sites

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']))

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.