gaugeboson Posted March 2, 2008 Share Posted March 2, 2008 <?php session_start(); require("config.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); if(isset($_SESSION['USERNAME']) == FALSE) { header("Location: " . $config_basedir); if($_POST['submit']) { $sql = "INSERT INTO categories(cat) VALUES('" . $_POST['cat'] . "');"; mysql_query($sql); header("Location: " . $config_basedir . " viewcat.php"); } else { require("header.php"); ?> <form action="<?php echo $SCRIPT_NAME ?>" method="post"> <table> <tr> <td>category</td> <td><input type="text" name="cat"></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="add entry"></td> </tr> </table> </form> <?php } require("footer.php"); ?> syntax error, unexpected $end (last line) Quote Link to comment Share on other sites More sharing options...
pocobueno1388 Posted March 2, 2008 Share Posted March 2, 2008 Just add another curly brace after the last one. Quote Link to comment Share on other sites More sharing options...
gaugeboson Posted March 2, 2008 Author Share Posted March 2, 2008 When I add the extra curly brace, I get a 404 error and it links back to the config_basedir. Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 2, 2008 Share Posted March 2, 2008 Try it this way... <?php session_start(); require("config.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); if(isset($_SESSION['USERNAME']) == FALSE) { header("Location: " . $config_basedir); if($_POST['submit']) { $sql = "INSERT INTO categories(cat) VALUES('" . $_POST['cat'] . "');"; mysql_query($sql); header("Location: " . $config_basedir . " viewcat.php"); } require("header.php"); ?> <form action="<?php echo $SCRIPT_NAME ?>" method="post"> <table> <tr> <td>category</td> <td><input type="text" name="cat"></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="add entry"></td> </tr> </table> </form> <?php } require("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
SNN Posted March 2, 2008 Share Posted March 2, 2008 <form action="<?php echo $SCRIPT_NAME ?>" method="post"> Needs to be: <form action="<?php echo $SCRIPT_NAME; ?>" method="post"> Remember, you must always have a semicolon for things like that. [edit below](Fixed code) <?php session_start(); require("config.php"); $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); if(isset($_SESSION['USERNAME']) == FALSE) { header("Location: " . $config_basedir); if($_POST['submit']) { $sql = "INSERT INTO categories(cat) VALUES('" . $_POST['cat'] . "');"; mysql_query($sql); header("Location: " . $config_basedir . " viewcat.php"); } else { require("header.php"); ?> <form action="<?php echo $SCRIPT_NAME; ?>" method="post"> <table> <tr> <td>category</td> <td><input type="text" name="cat"></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="add entry"></td> </tr> </table> </form> <?php } require("footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
trq Posted March 2, 2008 Share Posted March 2, 2008 Or even... <form action="" method="post"> Quote Link to comment Share on other sites More sharing options...
gaugeboson Posted March 2, 2008 Author Share Posted March 2, 2008 Well none of those modifications makes a difference. It links to the config_basedir and then says 404 error, is there something about this config_basedir? I have used it without issue for other pages though. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 2, 2008 Share Posted March 2, 2008 Well none of those modifications makes a difference. It links to the config_basedir and then says 404 error, is there something about this config_basedir? I have used it without issue for other pages though. thats because the var doesnt exist, which leads you to a page that doesnt exist (404) header("Location: " . $config_basedir); Where did you set the config_basedir? Should be: Change the value of the $config_basedir to your own <?php session_start(); require("config.php"); $config_basedir = "http://www.somewhereInyoursite.com"; $db = mysql_connect($dbhost, $dbuser, $dbpassword); mysql_select_db($dbdatabase, $db); if(isset($_SESSION['USERNAME']) == FALSE) { header("Location: " . $config_basedir); if($_POST['submit']) { $sql = "INSERT INTO categories(cat) VALUES('" . $_POST['cat'] . "');"; mysql_query($sql); header("Location: " . $config_basedir . " viewcat.php"); } else { require("header.php"); ?> <form action="" method="post"> <table> <tr> <td>category</td> <td><input type="text" name="cat"></td> </tr> <tr> <td></td> <td><input type="submit" name="submit" value="add entry"></td> </tr> </table> </form> <?php } require("footer.php"); } ?> Quote Link to comment Share on other sites More sharing options...
gaugeboson Posted March 2, 2008 Author Share Posted March 2, 2008 What should exactly be in place for the config_basedir? The current value I have is http://127.0.0.1/sites/blogtastic -which isn't a page. I guess I am kinda confused as to the purpose of this. Quote Link to comment Share on other sites More sharing options...
alecks Posted March 2, 2008 Share Posted March 2, 2008 http://127.0.0.1/sites/blogtastic -> http://127.0.0.1/sites/blogtastic/ Quote Link to comment Share on other sites More sharing options...
phpSensei Posted March 2, 2008 Share Posted March 2, 2008 What should exactly be in place for the config_basedir? The current value I have is http://127.0.0.1/sites/blogtastic -which isn't a page. I guess I am kinda confused as to the purpose of this. I will get to that in a minute, but you see your code doesnt make sense. Once The Username Session is False, then that missing bracket you were asked to put at the end of your script was wrong. First of all, change that piece of code: if(isset($_SESSION['USERNAME']) == FALSE) { header("Location: " . $config_basedir); to if(isset($_SESSION['USERNAME']) == FALSE) { header("Location: " . $config_basedir); } And Remove the bracket you were asked to add. Now the config_basedir is up to you, or who ever coded this. Its the url the user is redirected to if the user isnt logged in. I supose it would be the Login page of your site? Or I might be wrong, but who ever coded this intented the config_basedir to be a directory plugged into the header location... 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.