Jump to content

Header not working.......


arunpatal

Recommended Posts

<script>

function check_field(){

document.getElementById("guest_form").submit() 
}

</script>

<?php


if (isset($_POST["name"]) AND $_POST["name"] = "name"){

	header("location:page.php"); }	
?>

<form method="post" id="guest_form">
<input type="text" value="abc" name="name" />
<input type="button" value="Sub" onclick="check_field()" id="aa" />
</form>

When am running this code on my pc (xampp), It is running fine.

But when i upload the file on server (godaddy).....

it does not redirect....... or the header is not working

Link to comment
https://forums.phpfreaks.com/topic/287602-header-not-working/
Share on other sites

you cannot output ANYTHING to the browser before a header() statement. your javascirpt code is output that is being sent to the browser and cannot come before a header(), a session_start(), setcookie()... statement.

 

the only reason this works on your development system is because php thought it would be fun to waste your time developing code that wouldn't run on every system.

 

your development system has an output_buffer setting in the php.ini that should be turned off, so that code you develop will work, with regards to header() statements, on every system. stop and start your web server on your development system to get any change made to the php.ini to take effect.

Link to comment
https://forums.phpfreaks.com/topic/287602-header-not-working/#findComment-1475351
Share on other sites

should be a double == when checking against something, a single when setting

if (isset($_POST['name']) AND $_POST['name'] == "name"){

in your post form you set the value as abc, so it should be this

if (isset($_POST['name']) AND $_POST['name'] == "abc"){
Link to comment
https://forums.phpfreaks.com/topic/287602-header-not-working/#findComment-1475352
Share on other sites

the single = in your posted code is a problem, because the conditional test will always be true if the post variable is set, regardless of the value in it.

 

for your solution, i was hoping that you would rearrange the code on your page so that it was correctly organized as a web page.

Link to comment
https://forums.phpfreaks.com/topic/287602-header-not-working/#findComment-1475392
Share on other sites

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.