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
https://forums.phpfreaks.com/topic/216671-simple-_post-problem/
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.

 

 

Try something like this...

 

<?php
if (empty($_POST['reg']) || empty($_POST['title'])) {
  $fillinform = "Please fill in all the form to add a listing.";
  // anything else you can think of here
} else {
  // Then place your positive outcome here
}
?>

 

Good Luck

- tony

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.