Jump to content
Sign in to follow this  
ukweb

statement not working (again)

Recommended Posts

Hi

 

In all my time developing php apps have i ever encountered so many problems as I have with this project. It has been some time since I last developed anything like this but it is really winding me up as i cannot see where the problems are.

 

The problem page is here:

 

[a href=\"http://www.servewales.co.uk/members/register.php\" target=\"_blank\"]http://www.servewales.co.uk/members/register.php[/a]

 

and it is not supposed to display "you did not specify your first name" unless there is a get variable called action which is set to confirm. Here is the code for this line of text:

 

<?php if ( $_POST['first_name']  == '' &&  $_GET['action'] == 'confirm'  ) { ?>
You did not specify your first name
<?php } 
if ( ! ($_POST['first_name'] == "") ) {
$v3 = "1";
}
?>

 

THe last bit of code just sets a value for $v3 which works fine.

 

HELP PLEASE!

Share this post


Link to post
Share on other sites

Have you put any debugging lines in your code so you can see what you are actually testing against?

<?php
echo '<pre> $_POST: ' . print_r($_POST,true) . '</pre>'; // debug
echo '<pre> $_GET: ' . print_r($_GET,true) . '</pre>';    // debug
if ($_POST['first_name']  == '' &&  $_GET['action'] == 'confirm') 
    echo 'You did not specify your first name';
if ($_POST['first_name'] != '')
    $v3 = "1";
?>

 

Ken

Share this post


Link to post
Share on other sites

well at some point in time the 2 conditions of your if statement are being met, and therefore that message is displaying. but you need to post more code than that. there is no way to find the bug based on that.

Share this post


Link to post
Share on other sites

Post some of your code so we can help out.

 

you could try this

 

if ($_POST['first_name']  == '' &&  $_GET['action'] == 'confirm'){
    echo 'You did not specify your first name';
} else {
echo ' ';
}
if ($_POST['first_name'] != ''){
$v3 = "1";
}

use   and not just a space because mose tables will not print a space so you need the code FOR a space to print.

 

Ray

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

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.