Jump to content

Need some help.


esahp

Recommended Posts

I have a form setup, and after the user hits send it will go to another php page for processing using POST. This seems to work fine, until I get to the second page and hit back to the form, then it seems to desync or something? Then I'll change some stuff to test it and along with displaying the messages that something is wrong, it also displays the message [b]Works, all clear.[/b]. Is there a way to stop this from happening?
[code]
<?
  $firstname = $_POST['firstname'];
  $lastname = $_POST['lastname'];
  $email = $_POST['email'];
  $phonenumber = $_POST['phonenumber'];
  $homeaddress = $_POST['homeaddress'];
  $citystate = $_POST['citystate'];
  $country = $_POST['country'];
  $domainname = $_POST['domainname'];
  $username = $_POST['username'];
  $password1 = $_POST['password1'];
  $password2 = $_POST['password2'];
  $rules = $_POST['rules'];
  $legalinfo = $_POST['legalinfo'];
  $age = $_POST['age'];
  $sitedetails = $_POST['sitedetails'];
  $aboutus = $_POST['aboutus'];
  if ($firstname == "") { echo "First Name field was left blank.<br />"; }
  if ($lastname == "") { echo "Last Name field was left blank.<br />"; }
  if ($email == "") { echo "Email Address field was left blank.<br />"; }
  if ($phonenumber == "") { echo "Phone Number field was left blank.<br />"; }
  if ($homeaddress == "") { echo "Home Address Field was left blank.<br />"; }
  if ($citystate == "") { echo "City&State field was left blank.<br />"; }
  if ($country == "") { echo "Country field was left blank.<br />"; }
  if ($domainname == "") { echo "Your Domain field was left blank.<br />"; }
  if ($username == "") { echo "Desired Username field was left blank.<br />"; }
  if (($password1 == "") || ($password2 == "") || ($password1 != $password2)) { echo "Password fields were left blank or do not match.<br />"; }
  if ($rules == "") { echo "You didn't agree to the rules.<br />"; }
  if ($legalinfo == "") { echo "You didnt agree to the legal information.<br />"; }
  if ($age == "") { echo "You didnt state you were over the age of 18.<br />"; }
  if ($sitedetails == "") { echo "Site Details field was left blank.<br />"; }
  if ($aboutus == "") { echo "About Us field was left blank.<br />"; }
  else {
    echo "Works, all clear.";
  }
?>
[/code]
Link to comment
Share on other sites

1. I fill in the info so it will come up with 'Works all clear!'
2. I hit send
3. I am taken to the processing page and see the message 'Works, all clear.'.
4. I hit the [b]Back[/b] button on my browser (firefox).
5. I uncheck the rules checkbox
[code]<input type="checkbox" name="rules" value="rules"> I agree with the rules.<br />[/code]
6. I am now greeted on the processing page with:
[quote]
You didn't agree to the rules.
Works, all clear.
[/quote]

Tried to make that as simple as possible..
Link to comment
Share on other sites

idk try :

[code]
<?

  $firstname = $_POST['firstname'];
  $lastname = $_POST['lastname'];
  $email = $_POST['email'];
  $phonenumber = $_POST['phonenumber'];
  $homeaddress = $_POST['homeaddress'];
  $citystate = $_POST['citystate'];
  $country = $_POST['country'];
  $domainname = $_POST['domainname'];
  $username = $_POST['username'];
  $password1 = $_POST['password1'];
  $password2 = $_POST['password2'];
  $rules = $_POST['rules'];
  $legalinfo = $_POST['legalinfo'];
  $age = $_POST['age'];
  $sitedetails = $_POST['sitedetails'];
  $aboutus = $_POST['aboutus'];
  if ($firstname == "") { echo "First Name field was left blank.<br />"; error = 1}
  if ($lastname == "") { echo "Last Name field was left blank.<br />"; error = 1}
  if ($email == "") { echo "Email Address field was left blank.<br />"; error = 1}
  if ($phonenumber == "") { echo "Phone Number field was left blank.<br />"; error = 1}
  if ($homeaddress == "") { echo "Home Address Field was left blank.<br />"; error = 1}
  if ($citystate == "") { echo "City&State field was left blank.<br />"; error = 1}
  if ($country == "") { echo "Country field was left blank.<br />"; error = 1}
  if ($domainname == "") { echo "Your Domain field was left blank.<br />"; error = 1}
  if ($username == "") { echo "Desired Username field was left blank.<br />"; error = 1}
  if (($password1 == "") || ($password2 == "") || ($password1 != $password2)) { echo "Password fields were left blank or do not match.<br />"; error = 1}
  if ($rules == "") { echo "You didn't agree to the rules.<br />"; error = 1}
  if ($legalinfo == "") { echo "You didnt agree to the legal information.<br />"; error = 1}
  if ($age == "") { echo "You didnt state you were over the age of 18.<br />"; error = 1}
  if ($sitedetails == "") { echo "Site Details field was left blank.<br />"; error = 1}
  if ($aboutus == "") { echo "About Us field was left blank.<br />"; error = 1}
  if error = "" {
    echo "Works, all clear.";
  }
?>[/code]

my guess would be that when u said else it was only refering to the $aboutus string...
Link to comment
Share on other sites

I did some more poking around and came up with this solution, almost similar to yours (which gave me an error by the way):
[code]
<?
  $firstname = $_POST['firstname'];
  $lastname = $_POST['lastname'];
  $email = $_POST['email'];
  $phonenumber = $_POST['phonenumber'];
  $homeaddress = $_POST['homeaddress'];
  $citystate = $_POST['citystate'];
  $country = $_POST['country'];
  $domainname = $_POST['domainname'];
  $username = $_POST['username'];
  $password1 = $_POST['password1'];
  $password2 = $_POST['password2'];
  $rules = $_POST['rules'];
  $legalinfo = $_POST['legalinfo'];
  $age = $_POST['age'];
  $sitedetails = $_POST['sitedetails'];
  $aboutus = $_POST['aboutus'];
  if ($firstname == "") { $errors .= "First Name field was left blank.<br />"; }
  if ($lastname == "") { $errors .= "Last Name field was left blank.<br />"; }
  if ($email == "") { $errors .= "Email Address field was left blank.<br />"; }
  if ($phonenumber == "") { $errors .= "Phone Number field was left blank.<br />"; }
  if ($homeaddress == "") { $errors .= "Home Address Field was left blank.<br />"; }
  if ($citystate == "") { $errors .= "City&State field was left blank.<br />"; }
  if ($country == "") { $errors .= "Country field was left blank.<br />"; }
  if ($domainname == "") { $errors .= "Your Domain field was left blank.<br />"; }
  if ($username == "") { $errors .= "Desired Username field was left blank.<br />"; }
  if (($password1 == "") || ($password2 == "") || ($password1 != $password2)) { $errors .= "Password fields were left blank or do not match.<br />"; }
  if ($rules == "") { $errors .= "You didn't agree to the rules.<br />"; }
  if ($legalinfo == "") { $errors .= "You didnt agree to the legal information.<br />"; }
  if ($age == "") { $errors .= "You didnt state you were over the age of 18.<br />"; }
  if ($sitedetails == "") { $errors .= "Site Details field was left blank.<br />"; }
  if ($aboutus == "") { $errors .= "About Us field was left blank.<br />"; }
  if (!isset($errors)) {
    echo "all clear";
  }
  else {
    echo $errors;
  }
?>
[/code]
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.