Jump to content

Recommended Posts

Hi all, I am creating a login system for my site. So far the registration and login both work great, but I am having a problem redirecting a user to the myaccount.php page after a successful login. I was planning on having a link to continue to their profile page and was doing it like so:

<?php
		echo "<h2>Success! You are now logged in " . $_SESSION['username'] . "</h2><br><br>";
	  ?>
	  <h2>Click here to continue to your profile: <a href="myaccount.php?username

 

However, i am unsure of how to complete the link, or if that is even the correct way to do it. Would it be recommended to use header() instead? And if so how would I implement that in this situation so it doesnt automatically redirect?

 

Thanks in advance for any help!

Link to comment
https://forums.phpfreaks.com/topic/135389-help-with-user-account-page/
Share on other sites

Header would not work since you have output to the browser.

 

The best way to do this is to pass the user id over via a Session that way it can't be compromised.

 

So just send them to myaccount.php but in that page, use the Session for thier user id to pull up their relavent data.

Thanks for the previous help, I am now getting an error

 

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /d3/home/univ/cis450rb/public_html/index.php on line 194

 

The code that is trying to run is here:

if (!$con) 
    { 
        die('Could not connect: ' . mysql_error()); 
    } 

    @mysql_select_db($dbusername) or die("Unable to select database");

	$query = "select * from Opportunity" . 
			   "where oppId = 10";
			   
	$results = mysql_query( $query, $con );

	while ($row = mysql_fetch_array($results))
	{
		echo "<p>" . $results . "</p>";
	}

 

The while loop is where the error is being thrown. I know there is something I am missing, but cannot figure it out for the life of me. Any help is appreciated..thanks!

Chances are the opportunity and where are combined which is throwing an error:

 

      $query = "select * from Opportunity" .
               " where oppId = 10"; // added space here
               
      $results = mysql_query( $query, $con );

 

To have gotten the error this would have thrown it:

 

$results = mysql_query( $query, $con ) or die(mysql_error());

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.