Jump to content

Recommended Posts

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);?>

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">

 

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.