xx_princess_xx Posted May 8, 2009 Share Posted May 8, 2009 <form action=<?php echo $_SERVER[ 'PHP_SELF']; ?> method="post"> <frameset> <table border="0"> <tr> <td>Name:</td> <td><input type="text" name="aname" value="<?php echo $aname; ?>" /> <?php if($errorID==1) echo "* $errorMsg"; ?></td> </tr> <tr> <td>Address:</td> <td><input type="text" name="address" value="<?php echo $address; ?>" /> <?php if($errorID==2) echo "*$errorMsg"; ?></td> </tr> <tr> <td>Post Code:</td> <td><input type="text" name="post_code" value="<?php echo $post_code; ?>" /> <?php if($errorID==3) echo "*$errorMsg"; ?></td> </tr> <tr> <td></td> <td><input type="submit" /></td> </tr> </table> </frameset> </form> <?php if (isset($errorID) && $errorID==0) { header ("Location: index.php"); } ?> after the form coding, i want the page to be directed to another .php page, i tried using the header finction but it doesnt seam to work, is there something i am doing wrong. please help thank you Quote Link to comment Share on other sites More sharing options...
trq Posted May 8, 2009 Share Posted May 8, 2009 is there something i am doing wrong Yes, you are sending output prior to calling header. Try... <?php if ($_SERVER['REQUEST_METHOD'] == "GET") {?> <form action=<?php echo $_SERVER[ 'PHP_SELF']; ?> method="post"> <frameset> <table border="0"> <tr> <td>Name:</td> <td><input type="text" name="aname" value="<?php echo $aname; ?>" /> <?php if($errorID==1) echo "* $errorMsg"; ?></td> </tr> <tr> <td>Address:</td> <td><input type="text" name="address" value="<?php echo $address; ?>" /> <?php if($errorID==2) echo "*$errorMsg"; ?></td> </tr> <tr> <td>Post Code:</td> <td><input type="text" name="post_code" value="<?php echo $post_code; ?>" /> <?php if($errorID==3) echo "*$errorMsg"; ?></td> </tr> <tr> <td></td> <td><input type="submit" /></td> </tr> </table> </frameset> </form> <?php } else { if (isset($errorID) && $errorID == 0) { header ("Location: index.php"); } } ?> Quote Link to comment Share on other sites More sharing options...
xx_princess_xx Posted May 8, 2009 Author Share Posted May 8, 2009 I got this following error Parse error: parse error in C:\xampp\htdocs\EstateAgent\agents_insert.php on line 118 Quote Link to comment Share on other sites More sharing options...
Presto-X Posted May 8, 2009 Share Posted May 8, 2009 I'm not sure, but doesn't the else need to look like this? }else{ if (isset($errorID) && ($errorID == 0)) { header ("Location: index.php"); } } Quote Link to comment Share on other sites More sharing options...
xx_princess_xx Posted May 8, 2009 Author Share Posted May 8, 2009 it gives me the same error, is there supposed to be an else at the beginning? Quote Link to comment Share on other sites More sharing options...
Presto-X Posted May 8, 2009 Share Posted May 8, 2009 Try this: <?php if (isset($_POST['submit'])){ if (isset($errorID) && ($errorID == 0)) { header ("Location: index.php"); } } else { ?> <form action=<?php echo $_SERVER[ 'PHP_SELF']; ?> method="post"> <frameset> <table border="0"> <tr> <td>Name:</td> <td><input type="text" name="aname" value="<?php echo $aname; ?>" /> <?php if($errorID==1) echo "* $errorMsg"; ?></td> </tr> <tr> <td>Address:</td> <td><input type="text" name="address" value="<?php echo $address; ?>" /> <?php if($errorID==2) echo "*$errorMsg"; ?></td> </tr> <tr> <td>Post Code:</td> <td><input type="text" name="post_code" value="<?php echo $post_code; ?>" /> <?php if($errorID==3) echo "*$errorMsg"; ?></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" /></td> </tr> </table> </frameset> </form> <?PHP } ?> Quote Link to comment Share on other sites More sharing options...
xx_princess_xx Posted May 8, 2009 Author Share Posted May 8, 2009 still get the same error Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 What's the error and the line of code that it error on? Quote Link to comment Share on other sites More sharing options...
xx_princess_xx Posted May 8, 2009 Author Share Posted May 8, 2009 <?php if($_POST) //if page has been submitted { $errorID=0; $aname=$_POST[ 'aname']; $address=$_POST[ 'address']; $post_code=$_POST[ 'post_code']; if(trim($aname) =="") //Is the value empty? { $errorID=1; $errorMsg="Name cannot be an empty value!"; } elseif(trim($address) =="") //Is the value empty? { $errorID=2; $errorMsg="Address cannot be an empty value!"; } elseif(trim($post_code) =="") //Is the value empty? { $errorID=3; $errorMsg="Post Code cannot be an empty value!"; } } ?> <!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"><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" --> <head> <!-- InstanceBeginEditable name="head" --> <link rel="stylesheet" type="text/css" href="styles.css" media="all"/> <meta http-equiv="Content-Type"content="text/html;charset=iso-8859-1"/> <title>Angel Estates</title> <!-- InstanceEndEditable --> </head> <body> <div class="container"> <div class="shadow"> <div class="main"> <div class="banner"> <div class="title">Angel Estates</div> <!-- title --> </div> <!-- banner --> <div class="menu_container"> <div class="menu"><!-- InstanceBeginEditable name="menu" --> <ul class="menu"> <li><a href="index.php"><span>Home</span></a></li> <li><a href="search.php"><span>Search</span></a></li> <li><a href="agents.php" class="active"><span>Agents</span></a></li> <li><a href="tenants.php"><span>Tenants</span></a></li> <li><a href="properties.php"><span>Properties</span></a></li> </ul> <!-- InstanceEndEditable --></div> <!-- menu --> </div> <!--menu_container--> <div class="content"> <div class="left_panel"> <!-- InstanceBeginEditable name="left content" --> <p><a href="agents_insert.php" class="link" class="link_hover">Insert Agent Details</a></p> <p><a href="#" class="link" class="link_hover">Update Agent Details</a></p> <p><a href="#" class="link" class="link_hover">Delete Agent Details</a></p> <!-- InstanceEndEditable --></div> <!-- left_panel --> <div class="right_content"> <!-- InstanceBeginEditable name="right content" --> <p class="sub_title">Insert Agent Details</p> <?php if (isset($_POST['submit'])){ if (isset($errorID) && ($errorID == 0)) { header ("Location: index.php"); } } else { ?> <form action=<?php echo $_SERVER[ 'PHP_SELF']; ?> method="post"> <frameset> <table border="0"> <tr> <td>Name:</td> <td><input type="text" name="aname" value="<?php echo $aname; ?>" /> <?php if($errorID==1) echo "* $errorMsg"; ?></td> </tr> <tr> <td>Address:</td> <td><input type="text" name="address" value="<?php echo $address; ?>" /> <?php if($errorID==2) echo "*$errorMsg"; ?></td> </tr> <tr> <td>Post Code:</td> <td><input type="text" name="post_code" value="<?php echo $post_code; ?>" /> <?php if($errorID==3) echo "*$errorMsg"; ?></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" /></td> </tr> </table> </frameset> </form> <?PHP } ?> <!-- InstanceEndEditable --></div> <!-- right_content --> </div><!-- content --> </div><!-- main --> </div><!-- shadow --> </div><!-- container --> </body> <!-- InstanceEnd --></html> this is the error Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\EstateAgent\agents_insert.php:28) in C:\xampp\htdocs\EstateAgent\agents_insert.php on line 72 Quote Link to comment Share on other sites More sharing options...
trq Posted May 8, 2009 Share Posted May 8, 2009 You cannot send output prior to calling header. There is a MASSIVE sticky on the subject at the top of this board! Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 8, 2009 Share Posted May 8, 2009 Put your header above any HTML display. <?php if($_POST['submit']) //if page has been submitted { $errorID=0; $aname=$_POST[ 'aname']; $address=$_POST[ 'address']; $post_code=$_POST[ 'post_code']; if(trim($aname) =="") //Is the value empty? { $errorID=1; $errorMsg="Name cannot be an empty value!"; } elseif(trim($address) =="") //Is the value empty? { $errorID=2; $errorMsg="Address cannot be an empty value!"; } elseif(trim($post_code) =="") //Is the value empty? { $errorID=3; $errorMsg="Post Code cannot be an empty value!"; } if ($errorID == 0) { header ("Location: index.php"); } } ?> <!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"><!-- InstanceBegin template="/Templates/template.dwt" codeOutsideHTMLIsLocked="false" --> <head> <!-- InstanceBeginEditable name="head" --> <link rel="stylesheet" type="text/css" href="styles.css" media="all"/> <meta http-equiv="Content-Type"content="text/html;charset=iso-8859-1"/> <title>Angel Estates</title> <!-- InstanceEndEditable --> </head> <body> <div class="container"> <div class="shadow"> <div class="main"> <div class="banner"> <div class="title">Angel Estates</div> <!-- title --> </div> <!-- banner --> <div class="menu_container"> <div class="menu"><!-- InstanceBeginEditable name="menu" --> <ul class="menu"> <li><a href="index.php"><span>Home</span></a></li> <li><a href="search.php"><span>Search</span></a></li> <li><a href="agents.php" class="active"><span>Agents</span></a></li> <li><a href="tenants.php"><span>Tenants</span></a></li> <li><a href="properties.php"><span>Properties</span></a></li> </ul> <!-- InstanceEndEditable --></div> <!-- menu --> </div> <!--menu_container--> <div class="content"> <div class="left_panel"> <!-- InstanceBeginEditable name="left content" --> <p><a href="agents_insert.php" class="link" class="link_hover">Insert Agent Details</a></p> <p><a href="#" class="link" class="link_hover">Update Agent Details</a></p> <p><a href="#" class="link" class="link_hover">Delete Agent Details</a></p> <!-- InstanceEndEditable --></div> <!-- left_panel --> <div class="right_content"> <!-- InstanceBeginEditable name="right content" --> <p class="sub_title">Insert Agent Details</p> <form action=<?php echo $_SERVER[ 'PHP_SELF']; ?> method="post"> <frameset> <table border="0"> <tr> <td>Name:</td> <td><input type="text" name="aname" value="<?php echo $aname; ?>" /> <?php if($errorID==1) echo "* $errorMsg"; ?></td> </tr> <tr> <td>Address:</td> <td><input type="text" name="address" value="<?php echo $address; ?>" /> <?php if($errorID==2) echo "*$errorMsg"; ?></td> </tr> <tr> <td>Post Code:</td> <td><input type="text" name="post_code" value="<?php echo $post_code; ?>" /> <?php if($errorID==3) echo "*$errorMsg"; ?></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="submit" /></td> </tr> </table> </frameset> </form> <?PHP } ?> <!-- InstanceEndEditable --></div> <!-- right_content --> </div><!-- content --> </div><!-- main --> </div><!-- shadow --> </div><!-- container --> </body> <!-- InstanceEnd --></html> Quote Link to comment Share on other sites More sharing options...
xx_princess_xx Posted May 8, 2009 Author Share Posted May 8, 2009 thanks it worked Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.