Jump to content

*Simple $_POST problem


unistake

Recommended Posts

Hi all,

 

I have been working on this script for over 5 hours, the script used to work but I have recreated some html code in the html form and I think it may have something to do with why the script does not work but I can not see it.

 

Hopefully an extra pair of eyes can help.

 

The I have tested what the $_POST['title'] below echos in the php script and it does carry the value to the php page, but the IF statement does not work.

 

Here it is:

 

html form in a php page:

<form action="testform.php" method="post"> 
<fieldset style="border:none"> 
    <ul class="controls">
             <li> 
          <label for="label">Title</label> 
          <input name="title" id="title" type="text" class="text" maxlength="" value="grumman aa4"  /> 
     	    </li> 
             <li> 
            <label for="label">Aircraft Registration</label> 
	    <input name="reg" id="label" type="text" class="text" maxlength="6" value="G-qwea" style="text-transform:uppercase;"  /> 
    </li> 	   
             <li> 
         <input name="Button" type="submit" class="button centered" /> 							
            </li> </ul> 
            </fieldset></form> 

The part of the PHP page that does not work is below. If the php below just says if ($_POST['reg'] == "")... it works but as soon as I put || $_POST['title'] it does not work. I have also tried if ($_POST['reg'] && $_POST['title'] == "")... which DOES work?

 

 

testform.php

<?php

if ($_POST['reg'] || $_POST['title'] == "") {
$fillinform = "Please fill in all the form to add a listing.";
include("saleform.php");
exit();
}
?>

Link to comment
Share on other sites

The IF statement doesn't seem to work the way you want it too, I have had the same problem in the past.

 

Try the following...

<?php
if ($_POST['reg'] == "" || $_POST['title'] == "") {
$fillinform = "Please fill in all the form to add a listing.";
include("saleform.php");
exit();
}
?>

 

Tell me how this goes :)

 

Regards, Paul.

 

 

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.