Jump to content

IF ELSE LOGIC PROBLEM


sonved2004

Recommended Posts

Hi,

 

New to PHP but experienced programmer.

I need support on form validation. my code goes like this -

 

$URL="welcome.php"

 

if($flag <>"OK"){

echo "<center>$msg <br> <input type='button' value='Retry' onClick='history.go(-1)'></center>";

}else{header ("Location: $URL");

}

 

I expect that if the form validation found OK, (this part ->else{header ("Location: $URL");) a new page will be opened,

informing user that form has been submitted.

 

I have three pages like this - 1.Form.php  2.fvalidate.php    3.welcome.php

 

my form action opens fvalidate.php and if all is well it should take automatically to welcome.php

 

 

 

Can anybody help how to complete this else part in the above script? ???

Link to comment
Share on other sites

yes. following 12 lines are at the top of page..

 

<html>

<?php

$URL="welcome.php";

 

if($flag <>"OK"){

echo "<center>$msg <br> <input type='button' value='Retry' onClick='history.go(-1)'></center>";

}else{header ("Location: $URL");

exit;

}

?>

<script language="JavaScript" type="text/JavaScript">

<!--

Link to comment
Share on other sites

Don't do that, ob_start() isn't recommended.

 

Change your code to this:

 

<?php
$URL="welcome.php";

if($flag <>"OK"){
echo "<html><center>$msg
<input type='button' value='Retry' onClick='history.go(-1)'></center>";
}else{header ("Location: $URL");
exit;
}
?>
<script language="JavaScript" type="text/JavaScript">
<!--

Link to comment
Share on other sites

When you use ob_start() to hide header problems, you're not fixing the problem, just hiding it. You should fix the problem, which is probably due to a logic or program flow problem.  I, for one, have never understood why anyone would want to put out anything to the browser and then jump to another page.

 

Ken

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.