contra10 Posted December 31, 2008 Share Posted December 31, 2008 hi my header keeps directing me to http://localhost/profile/index.php when it should be http://localhost/profile/index.php?user=$id after post is clicked <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("registration") or die(mysql_error()); if(is_numeric($_GET['user'])){ $id = $_GET['user']; $postuser= "SELECT * FROM users WHERE id = '$id'"; $post = mysql_query($postuser) or die(mysql_error()); while ($posted = mysql_fetch_assoc($post)) { $usernamep = "{$posted['name']}"; } } if(isset($_COOKIE['ID_my_site'])) { $usernameq = $_COOKIE['ID_my_site']; $inpost = mysql_query("SELECT * FROM users WHERE username ='$usernameq'") or die (mysql_error()); while($rowpost = mysql_fetch_assoc($inpost)) { $userposting = "{$rowpost['username']}"; $userpostingid = "{$rowpost['id']}"; } } //This code runs if the form has been submitted if (isset($_POST['post'])) { //This makes sure they did not leave any fields blank if (!$_POST['userpost']){ die('You did not complete all of the required fields'); } $query2= "SELECT id FROM users WHERE username = '$username'"; $result2 = mysql_query($query2) or die(mysql_error()); $usera = mysql_fetch_assoc($result2); $userid = "{$usera['id']}"; $userpost = mysql_real_escape_string($_POST['userpost']); $postnamea = mysql_real_escape_string($_POST['profilename']); $ida = mysql_real_escape_string($_POST['profileid']); //This gets today's date $date = time () ; //This puts the day, month, and year in seperate variables $day = date('d', $date) ; $month = date('F', $date) ; $year = date('Y', $date) ; header("Location: http://localhost/profile/index.php?user=$id"); // now we insert it into the database $insert = "INSERT INTO post_profile (userid, username, postinguserid, postingusername, post, month, day, year) VALUES ('$id', '$username', '$userpostingid', '$usernameq', '$userpost', '$month', '$day', '$year')"; $add_group = mysql_query($insert) or die(mysql_error()); ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="500" align="center" height="100"> <tr> <td align="center"><textarea name="userpost" type="description" cols="50" rows="5" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea></td></tr> </tr> <tr><td align="center"><input type="submit" name="post" value="Post"></td></tr> </table> </form> <?php } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0" width="500" align="center" height="100"> <tr> <td align="center"><textarea name="userpost" type="description" cols="50" rows="5" maxlength="10" STYLE="color: #FFFFFF; font-family: Verdana; font-weight: bold; font-size: 12px; background-color: #72A4D2;"></textarea></td></tr> </tr> <tr><td align="center"><input type="submit" name="post" value="Post"></td></tr> </table> </form> <?php } ?> <?php echo ($id);?> <?php echo($username);?> <?php echo($usernameq);?> <?php echo($userpostingid);?> Quote Link to comment Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 You do realize the position of the header tag in your code makes no sense? Everything below it will not update and it will potentially throw you into an infinite loop. I would re look at your logic on that. Quote Link to comment Share on other sites More sharing options...
dennismonsewicz Posted December 31, 2008 Share Posted December 31, 2008 why are you redirecting using a header when your form is posting? just place this in your form change this: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> to this: <form action=""index.php?user=<?php echo $id; ?>" method="post"> Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 31, 2008 Author Share Posted December 31, 2008 i tried the <form action=""index.php?user=<?php echo $id; ?>" method="post"> but it didn't work i even tried to from it into this <form action="index.php?user=<?php echo ($id); ?>" method="post"> still didn't work... i guess i can change the header location if i user it in the php code but when i place it at the top near the isset post then i still don't get anywhere Quote Link to comment Share on other sites More sharing options...
contra10 Posted December 31, 2008 Author Share Posted December 31, 2008 btw i tried to redirect with only the form and i tried it with only the header neither 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.