> Hello
> thanks all for the help.
> The scripts are now working fine, but It doesnt display
> information or post by
> the user. Thanks again for all post.
>
> It showed these errors
>
> Warning: Cannot modify header information - headers already sent by
> (output started at /home/public_html/post1.php:11)
> in /home/public_html/post1.php on line 116
>
> Warning: Cannot modify header information - headers already sent by
> (output started at /home/public_html/post1.php:11)
> in /home/public_html/post1.php on line 117
>
> ==============
> <?php //connect to database
> include ("db_connect.php");
> $match = "SELECT id FROM registration WHERE username =
> '".$_POST['username']."' AND password = '".$_POST['password']."';";
> $qry = mysql_query($match)
> or die ("could not match data because ".mysql_error());
> $num_rows = mysql_num_rows ($qry);
> if ($num_rows <= 0)
> {
> echo "Sorry,there is no Username $username with the specified
> password.<br>";
> echo "<a href="" Again,</a>";
> exit;
> }else{
> // form and execute query statement
> $query = "SELECT first, family, email FROM registration WHERE
> username =
> '$username'";
> $result = mysql_query($query);
> // matches found, format records
> list ($first, $family, $email) = mysql_fetch_row ($result);
>
> print "<h2>User Information:</h2>";
> print "<b>First:</b> $first <br>";
> print "<b>Family:</b> $family <br>";
> print "<b>Email:</b> $email <br>";
> print "<h2>Post Information:</h2>";
> // form n execute 'post' query
>
> $query = "SELECT username, post, date FROM post WHERE username
> = '$username'
> ORDER BY date DESC";
> $result = mysql_query ($query);
>
> print "<table border = 1>";
> print "<tr><th>Username</th><th>Post</th><th>Date</th></tr>";
> // format and display return rows
>
> while (list ($username, $post, $date) = mysql_fetch_row
> ($result)):
> print "<tr>";
> print "<td>$username</td><td>$post</td><td>$date</td>";
> print "</tr>";
>
> endwhile;
> print "</table>";
>
> setcookie ("loggedin", "TRUE", time()+(3600 * 24));
> setcookie ("mysite_username", "$username");
>
> echo "You are now logged in!<br>";
> echo "Click Here:<a href="" Out.</a>";
> }?>
PHP requires that you perform any HTTP header actions, such as writing a cookie, before sending
any output to the browser as in a print or echo statement. If you read the error carefully, it
tells you this. It says that you tried to do an HTTP header write to set a cookie around line 116
but you had already performed a print or echo on line 11.
Attempting to write cookies, set session variables, or redirect to another URL using the header()
function in the wrong order is probably one of the top 5 errors asked about in this group.
You should arrange the logic of your program so that you can write cookies well before you do any
print statements. Otherwise, read up on output buffering (http://php.net/ob_start).
Incidentally, this error can occur if you have any static HTML output or even blank lines in your
source code before the opening php tag.
James
_____
James D. Keeline
http://www.Keeline.com http://www.Keeline.com/articles
http://Stratemeyer.org http://www.Keeline.com/TSCollection
http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Spring Semester January-June 2006. Two new class topics.
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
SPONSORED LINKS
| Php mysql | Job postings |
YAHOO! GROUPS LINKS
- Visit your group "php-list" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
