sea4me
03-03-2009, 05:28 AM
Ok I have this script that works perfectly on my other host (PHP4) but after I switched to another host (PHP5) my page seems to stop redirecting.
Here is my code:
<?php
mysql_connect("localhost", "******", "*******") or die(mysql_error());
mysql_select_db("*****") or die(mysql_error());
$customerid="1"; //it's part of a system but now it's just static
$cart="1"; //it's part of a system but now it's just static
if (!empty($_GET['action'])){ $action = $_GET['action']; }
if ($action=="notes"){
if (!empty($_POST['cart'])){ $cart = $_POST['cart']; } else { $cart="1"; }
if (!empty($_POST['jobname'])){ $jobname = $_POST['jobname']; }
if (!empty($_POST['add'])){ $add = $_POST['add']; }
if (!empty($_POST['city'])){ $city = $_POST['city']; }
if (!empty($_POST['state'])){ $state = $_POST['state']; }
if (!empty($_POST['zip'])){ $zip = $_POST['zip']; }
if (!empty($_POST['tel'])){ $tel = $_POST['tel']; }
if (!empty($_POST['email'])){ $email = $_POST['email']; }
if (!empty($_POST['status'])){ $status = $_POST['status']; }
if (!empty($_POST['memo'])){ $memo = $_POST['memo']; }
$query = "SELECT * FROM notes WHERE CUSTOMERID = '".$customerid."' AND CART = '".$cart."' AND `ORDERID`='0'";
$sql = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($sql);
if ($count == 0) {
$query = "INSERT INTO `notes` ( `CUSTOMERID` , `CART` , `JOBNAME` , `TEL` , `ADDRESS` , `CITY`, `STATE`, `ZIP`, `EMAIL`, `STATUS`, `MEMO`) VALUES ('".$customerid."', '".$cart."', '".$jobname."', '".$tel."', '".$add."', '".$city."', '".$state."', '".$zip."', '".$email."', '".$status."', '".$memo."')";
$sql = mysql_query($query) or die(mysql_error());
}
else {
$query = "UPDATE `notes` SET `JOBNAME` = '".$jobname."',`TEL` = '".$tel."', `ADDRESS` = '".$add."', `CITY` = '".$city."', `STATE` = '".$state."', `ZIP` = '".$zip."', `EMAIL` = '".$email."', `STATUS` = '".$status."', `MEMO` = '".$memo."' WHERE `CUSTOMERID` = '".$customerid."' AND `CART` = '".$cart."' AND `ORDERID`='0'";
$sql = mysql_query($query) or die(mysql_error());
}
header( "Location: index.html" ) ;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title></title>
</head>
<body>
<form action="notes.php?action=notes" method="post">
<input name="cart" type="hidden" value="<?php echo $cart; ?>" />
<?php
$query = "SELECT * FROM notes WHERE CUSTOMERID = '".$customerid."' AND CART = '".$cart."' AND ORDERID = '0' LIMIT 1";
$sql = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_row($sql)) {
$jobname = $row[3];
$tel = $row[4];
$add = $row[5];
$city = $row[6];
$state = $row[7];
$zip = $row[8];
$email = $row[9];
$status = $row[10];
$memo = $row[11];
}
?>
<table style="text-align:left">
<tr>
<td colspan="2">Jobname:<br /><input name="jobname" type="text" size="40" value="<?php echo $jobname;?>" /></td>
<td colspan="1">Phone:<br /> <input name="tel" type="text" size="25" value="<?php echo $tel;?>" /></td>
</tr><tr>
<td colspan="3">Address:<br /> <input name="add" type="text" size="70" value="<?php echo $add;?>" /></td>
</tr><tr>
<td>City: <br /><input name="city" type="text" size="30" value="<?php echo $city;?>" /></td>
<td>State: <br /><input name="state" type="text" size="10" value="<?php echo $state;?>" /></td>
<td>Zip: <br /><input name="zip" type="text" size="20" value="<?php echo $zip;?>" /></td>
</tr><tr>
<td colspan="2">Email: <br /><input name="email" type="text" size="40" value="<?php echo $email;?>" /></td>
<td colspan="1">Status: <br />
<select name="status">
<option value="Estimated" <?php if(!empty($status) && $status=="Estimated"){echo "selected";} ?>>Estimated</option>
<option value="Pending" <?php if(!empty($status) && $status=="Pending"){echo "selected";} ?>>Pending</option>
<option value="Paid" <?php if(!empty($status) && $status=="Paid"){echo "selected";} ?>>Paid</option>
</select>
</td>
</tr><tr>
<td colspan="3">Memo: <br /><textarea name="memo" cols="20" rows="10"><?php echo $memo;?></textarea></td>
</tr><tr>
<td></td>
<td ><input name="cart<?php echo $cart; ?>" type="submit" value="Update Job Info" /></td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
The page shows up as blank after I press submit and it stays at the same page! :mad:
Is header not allowed to be inside an if statement in PHP5?
If a create a very simple page it redirects:
<?php
header('Location: index.php' );
?>
Thank you!
Here is my code:
<?php
mysql_connect("localhost", "******", "*******") or die(mysql_error());
mysql_select_db("*****") or die(mysql_error());
$customerid="1"; //it's part of a system but now it's just static
$cart="1"; //it's part of a system but now it's just static
if (!empty($_GET['action'])){ $action = $_GET['action']; }
if ($action=="notes"){
if (!empty($_POST['cart'])){ $cart = $_POST['cart']; } else { $cart="1"; }
if (!empty($_POST['jobname'])){ $jobname = $_POST['jobname']; }
if (!empty($_POST['add'])){ $add = $_POST['add']; }
if (!empty($_POST['city'])){ $city = $_POST['city']; }
if (!empty($_POST['state'])){ $state = $_POST['state']; }
if (!empty($_POST['zip'])){ $zip = $_POST['zip']; }
if (!empty($_POST['tel'])){ $tel = $_POST['tel']; }
if (!empty($_POST['email'])){ $email = $_POST['email']; }
if (!empty($_POST['status'])){ $status = $_POST['status']; }
if (!empty($_POST['memo'])){ $memo = $_POST['memo']; }
$query = "SELECT * FROM notes WHERE CUSTOMERID = '".$customerid."' AND CART = '".$cart."' AND `ORDERID`='0'";
$sql = mysql_query($query) or die(mysql_error());
$count = mysql_num_rows($sql);
if ($count == 0) {
$query = "INSERT INTO `notes` ( `CUSTOMERID` , `CART` , `JOBNAME` , `TEL` , `ADDRESS` , `CITY`, `STATE`, `ZIP`, `EMAIL`, `STATUS`, `MEMO`) VALUES ('".$customerid."', '".$cart."', '".$jobname."', '".$tel."', '".$add."', '".$city."', '".$state."', '".$zip."', '".$email."', '".$status."', '".$memo."')";
$sql = mysql_query($query) or die(mysql_error());
}
else {
$query = "UPDATE `notes` SET `JOBNAME` = '".$jobname."',`TEL` = '".$tel."', `ADDRESS` = '".$add."', `CITY` = '".$city."', `STATE` = '".$state."', `ZIP` = '".$zip."', `EMAIL` = '".$email."', `STATUS` = '".$status."', `MEMO` = '".$memo."' WHERE `CUSTOMERID` = '".$customerid."' AND `CART` = '".$cart."' AND `ORDERID`='0'";
$sql = mysql_query($query) or die(mysql_error());
}
header( "Location: index.html" ) ;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title></title>
</head>
<body>
<form action="notes.php?action=notes" method="post">
<input name="cart" type="hidden" value="<?php echo $cart; ?>" />
<?php
$query = "SELECT * FROM notes WHERE CUSTOMERID = '".$customerid."' AND CART = '".$cart."' AND ORDERID = '0' LIMIT 1";
$sql = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_row($sql)) {
$jobname = $row[3];
$tel = $row[4];
$add = $row[5];
$city = $row[6];
$state = $row[7];
$zip = $row[8];
$email = $row[9];
$status = $row[10];
$memo = $row[11];
}
?>
<table style="text-align:left">
<tr>
<td colspan="2">Jobname:<br /><input name="jobname" type="text" size="40" value="<?php echo $jobname;?>" /></td>
<td colspan="1">Phone:<br /> <input name="tel" type="text" size="25" value="<?php echo $tel;?>" /></td>
</tr><tr>
<td colspan="3">Address:<br /> <input name="add" type="text" size="70" value="<?php echo $add;?>" /></td>
</tr><tr>
<td>City: <br /><input name="city" type="text" size="30" value="<?php echo $city;?>" /></td>
<td>State: <br /><input name="state" type="text" size="10" value="<?php echo $state;?>" /></td>
<td>Zip: <br /><input name="zip" type="text" size="20" value="<?php echo $zip;?>" /></td>
</tr><tr>
<td colspan="2">Email: <br /><input name="email" type="text" size="40" value="<?php echo $email;?>" /></td>
<td colspan="1">Status: <br />
<select name="status">
<option value="Estimated" <?php if(!empty($status) && $status=="Estimated"){echo "selected";} ?>>Estimated</option>
<option value="Pending" <?php if(!empty($status) && $status=="Pending"){echo "selected";} ?>>Pending</option>
<option value="Paid" <?php if(!empty($status) && $status=="Paid"){echo "selected";} ?>>Paid</option>
</select>
</td>
</tr><tr>
<td colspan="3">Memo: <br /><textarea name="memo" cols="20" rows="10"><?php echo $memo;?></textarea></td>
</tr><tr>
<td></td>
<td ><input name="cart<?php echo $cart; ?>" type="submit" value="Update Job Info" /></td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
The page shows up as blank after I press submit and it stays at the same page! :mad:
Is header not allowed to be inside an if statement in PHP5?
If a create a very simple page it redirects:
<?php
header('Location: index.php' );
?>
Thank you!