Jump to content

Social network (After Log in, redirected to the profile page)


Tranceprofile

Recommended Posts

Hi phpfreaks members,

 

I got a little social network website, http://www.tranceprofile.com

 

I got a php script for members to log in to my website.

When they are logged in they can view there own profile and edit it.

 

I got my login script on two places, http:www.tranceprofile.com/login.php

and my index.php page.

 

Well here is my problem: When they log in they are send to my index.php page as a logged in user.

I want them to be redirected to the http://www.tranceprofile.com/profile.php page.

 

I hope you guys can help me out!

 

Best regards, Mitch Oosterhuis.

 

Login script:

 

<table width="400" align="center" cellpadding="6" style="background-color:#FFF; border:#666 1px solid;">

  <form action="login.php" method="post" enctype="multipart/form-data" name="signinform" id="signinform">

    <tr>

      <td width="23%"><font size="+2">Log In</font></td>

      <td width="77%"><font color="#FF0000"><?php print "$errorMsg"; ?></font></td>

    </tr>

    <tr>

      <td><strong>Email:</strong></td>

      <td><input name="email" type="text" id="email" style="width:60%;" /></td>

    </tr>

    <tr>

      <td><strong>Password:</strong></td>

      <td><input name="pass" type="password" id="pass" maxlength="24" style="width:60%;"/></td>

    </tr>

  <tr>

      <td align="right"> </td>

      <td><input name="remember" type="checkbox" id="remember" value="yes" checked="checked" />

        Remember Me</td>

    </tr>

    <tr>

      <td> </td>

      <td><input name="myButton" type="submit" id="myButton" value="Sign In" /></td>

    </tr>

    <tr>

      <td> </td>

      <td> </td>

    </tr>

    <tr>

      <td colspan="2">Forgot your password? <a href="forgot_pass.php">Click Here</a>

  <br /></td>

    </tr>

    <tr>

      <td colspan="2">Need an Account? <a href="register.php">Click Here</a><br />        <br /></td>

    </tr>

  </form>

</table>

 

[attachment deleted by admin]

Link to comment
Share on other sites

Sorry guys, forgot this page.

 

<?php
session_start(); // Start Session First Thing
// Force script errors and warnings to show on page in case php.ini file is set to not display them
error_reporting(E_ALL);
ini_set('display_errors', '1');
//-----------------------------------------------------------------------------------------------------------------------------------
include_once "connect_to_mysql.php"; // Connect to the database
$dyn_www = $_SERVER['HTTP_HOST']; // Dynamic www.domainName available now to you in all of your scripts that include this file
//------ CHECK IF THE USER IS LOGGED IN OR NOT AND GIVE APPROPRIATE OUTPUT -------
$logOptions = ''; // Initialize the logOptions variable that gets printed to the page
// If the session variable and cookie variable are not set this code runs
if (!isset($_SESSION['idx'])) { 
  if (!isset($_COOKIE['idCookie'])) {
     $logOptions = '<a href="http://' . $dyn_www . '/register.php">Register Account</a>
    |    
 <a href="http://' . $dyn_www . '/login.php">Log In</a>';
   }
}
// If session ID is set for logged in user without cookies remember me feature set
if (isset($_SESSION['idx'])) { 
    
$decryptedID = base64_decode($_SESSION['idx']);
$id_array = explode("p3h9xfn8sq03hs2234", $decryptedID);
$logOptions_id = $id_array[1];
    $logOptions_username = $_SESSION['username'];
    $logOptions_username = substr('' . $logOptions_username . '', 0, 15); // cut user name down in length if too long

// Check if this user has any new PMs and construct which envelope to show
$sql_pm_check = mysql_query("SELECT id FROM private_messages WHERE to_id='$logOptions_id' AND opened='0' LIMIT 1");
$num_new_pm = mysql_num_rows($sql_pm_check);
if ($num_new_pm > 0) {
	$PM_envelope = '<a href="pm_inbox.php"><img src="../images/pm2.gif" width="18" height="11" alt="PM" /></a>';
} else {
	$PM_envelope = '<a href="pm_inbox.php"><img src="../images/pm1.gif" width="18" height="11" alt="PM" /></a>';
}
    // Ready the output for this logged in user
    $logOptions = $PM_envelope . '    
<a href="http://' . $dyn_www . '/profile.php?id=' . $logOptions_id . '">Profile</a>
   |  
<div class="dc">
<a href="#" onclick="return false">Account   <img src="../images/darr.gif" width="10" height="5" alt="Account Options" border="0"/></a>
<ul>
<li><a href="http://' . $dyn_www . '/edit_profile.php">Account Options</a></li>
<li><a href="http://' . $dyn_www . '/pm_inbox.php">Inbox Messages</a></li>
<li><a href="http://' . $dyn_www . '/pm_sentbox.php">Sent Messages</a></li>
</ul>
</div>

   |  
<a href="http://' . $dyn_www . '/logout.php">Log Out</a>';

} else if (isset($_COOKIE['idCookie'])) {// If id cookie is set, but no session ID is set yet, we set it below and update stuff

$decryptedID = base64_decode($_COOKIE['idCookie']);
$id_array = explode("nm2c0c4y3dn3727553", $decryptedID);
$userID = $id_array[1]; 
$userPass = $_COOKIE['passCookie'];
// Get their user first name to set into session var
    $sql_uname = mysql_query("SELECT username FROM myMembers WHERE id='$userID' AND password='$userPass' LIMIT 1");
$numRows = mysql_num_rows($sql_uname);
if ($numRows == 0) {
	echo 'Something appears wrong with your stored log in credentials. <a href="login.php">Log in again here please</a>';
	exit();
}
    while($row = mysql_fetch_array($sql_uname)){ 
    $username = $row["username"];
}

    $_SESSION['id'] = $userID; // now add the value we need to the session variable
$_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$userID");
    $_SESSION['username'] = $username;

    $logOptions_id = $userID;
    $logOptions_uname = $username;
    $logOptions_uname = substr('' . $logOptions_uname . '', 0, 15); 
    ///////////          Update Last Login Date Field       /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$logOptions_id'"); 
    // Ready the output for this logged in user
    // Check if this user has any new PMs and construct which envelope to show
$sql_pm_check = mysql_query("SELECT id FROM private_messages WHERE to_id='$logOptions_id' AND opened='0' LIMIT 1");
$num_new_pm = mysql_num_rows($sql_pm_check);
if ($num_new_pm > 0) {
	$PM_envelope = '<a href="pm_inbox.php"><img src="../images/pm2.gif" width="18" height="11" alt="PM" /></a>';
} else {
	$PM_envelope = '<a href="pm_inbox.php"><img src="../images/pm1.gif" width="18" height="11" alt="PM" /></a>';
}
// Ready the output for this logged in user
     $logOptions = $PM_envelope . '    
 <a href="http://' . $dyn_www . '/profile.php?id=' . $logOptions_id . '">Profile</a>
   |  
<div class="dc">
<a href="#" onclick="return false">Account   <img src="../images/darr.gif" width="10" height="5" alt="Account Options" border="0"/></a>
<ul>
<li><a href="http://' . $dyn_www . '/edit_profile.php">Account Options</a></li>
<li><a href="http://' . $dyn_www . '/pm_inbox.php">Inbox Messages</a></li>
<li><a href="http://' . $dyn_www . '/pm_sentbox.php">Sent Messages</a></li>
</ul>
</div>

   |  
<a href="http://' . $dyn_www . '/logout.php">Log Out</a>';
}
?>

Link to comment
Share on other sites

Hi phpfreaks members,

 

I got a little social network website, http://www.tranceprofile.com

 

I got a php script for members to log in to my website.

When they are logged in they can view there own profile and edit it.

 

I got my login script on two places, http:www.tranceprofile.com/login.php

and my index.php page.

 

Well here is my problem: When they log in they are send to my index.php page as a logged in user.

I want them to be redirected to the http://www.tranceprofile.com/profile.php page.

 

I hope you guys can help me out!

 

Best regards, Mitch Oosterhuis.

 

Login Script:

<table width="400" align="center" cellpadding="6" style="background-color:#FFF; border:#666 1px solid;">
  <form action="login.php" method="post" enctype="multipart/form-data" name="signinform" id="signinform">
    <tr>
      <td width="23%"><font size="+2">Log In</font></td>
      <td width="77%"><font color="#FF0000"><?php print "$errorMsg"; ?></font></td>
    </tr>
    <tr>
      <td><strong>Email:</strong></td>
      <td><input name="email" type="text" id="email" style="width:60%;" /></td>
    </tr>
    <tr>
      <td><strong>Password:</strong></td>
      <td><input name="pass" type="password" id="pass" maxlength="24" style="width:60%;"/></td>
    </tr>
  <tr>
      <td align="right"> </td>
      <td><input name="remember" type="checkbox" id="remember" value="yes" checked="checked" />
        Remember Me</td>
    </tr>
    <tr>
      <td> </td>
      <td><input name="myButton" type="submit" id="myButton" value="Sign In" /></td>
    </tr>
    <tr>
      <td> </td>
      <td> </td>
    </tr>
    <tr>
      <td colspan="2">Forgot your password? <a href="forgot_pass.php">Click Here</a>
  <br /></td>
    </tr>
    <tr>
      <td colspan="2">Need an Account? <a href="register.php">Click Here</a><br />        <br /></td>
    </tr>
  </form>
</table>

 

Second script:

<?php
session_start(); // Start Session First Thing
// Force script errors and warnings to show on page in case php.ini file is set to not display them
error_reporting(E_ALL);
ini_set('display_errors', '1');
//-----------------------------------------------------------------------------------------------------------------------------------
include_once "connect_to_mysql.php"; // Connect to the database
$dyn_www = $_SERVER['HTTP_HOST']; // Dynamic www.domainName available now to you in all of your scripts that include this file
//------ CHECK IF THE USER IS LOGGED IN OR NOT AND GIVE APPROPRIATE OUTPUT -------
$logOptions = ''; // Initialize the logOptions variable that gets printed to the page
// If the session variable and cookie variable are not set this code runs
if (!isset($_SESSION['idx'])) { 
  if (!isset($_COOKIE['idCookie'])) {
     $logOptions = '<a href="http://' . $dyn_www . '/register.php">Register Account</a>
    |    
 <a href="http://' . $dyn_www . '/login.php">Log In</a>';
   }
}
// If session ID is set for logged in user without cookies remember me feature set
if (isset($_SESSION['idx'])) { 
    
$decryptedID = base64_decode($_SESSION['idx']);
$id_array = explode("p3h9xfn8sq03hs2234", $decryptedID);
$logOptions_id = $id_array[1];
    $logOptions_username = $_SESSION['username'];
    $logOptions_username = substr('' . $logOptions_username . '', 0, 15); // cut user name down in length if too long

// Check if this user has any new PMs and construct which envelope to show
$sql_pm_check = mysql_query("SELECT id FROM private_messages WHERE to_id='$logOptions_id' AND opened='0' LIMIT 1");
$num_new_pm = mysql_num_rows($sql_pm_check);
if ($num_new_pm > 0) {
	$PM_envelope = '<a href="pm_inbox.php"><img src="../images/pm2.gif" width="18" height="11" alt="PM" /></a>';
} else {
	$PM_envelope = '<a href="pm_inbox.php"><img src="../images/pm1.gif" width="18" height="11" alt="PM" /></a>';
}
    // Ready the output for this logged in user
    $logOptions = $PM_envelope . '    
<a href="http://' . $dyn_www . '/profile.php?id=' . $logOptions_id . '">Profile</a>
   |  
<div class="dc">
<a href="#" onclick="return false">Account   <img src="../images/darr.gif" width="10" height="5" alt="Account Options" border="0"/></a>
<ul>
<li><a href="http://' . $dyn_www . '/edit_profile.php">Account Options</a></li>
<li><a href="http://' . $dyn_www . '/pm_inbox.php">Inbox Messages</a></li>
<li><a href="http://' . $dyn_www . '/pm_sentbox.php">Sent Messages</a></li>
</ul>
</div>

   |  
<a href="http://' . $dyn_www . '/logout.php">Log Out</a>';

} else if (isset($_COOKIE['idCookie'])) {// If id cookie is set, but no session ID is set yet, we set it below and update stuff

$decryptedID = base64_decode($_COOKIE['idCookie']);
$id_array = explode("nm2c0c4y3dn3727553", $decryptedID);
$userID = $id_array[1]; 
$userPass = $_COOKIE['passCookie'];
// Get their user first name to set into session var
    $sql_uname = mysql_query("SELECT username FROM myMembers WHERE id='$userID' AND password='$userPass' LIMIT 1");
$numRows = mysql_num_rows($sql_uname);
if ($numRows == 0) {
	echo 'Something appears wrong with your stored log in credentials. <a href="login.php">Log in again here please</a>';
	exit();
}
    while($row = mysql_fetch_array($sql_uname)){ 
    $username = $row["username"];
}

    $_SESSION['id'] = $userID; // now add the value we need to the session variable
$_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$userID");
    $_SESSION['username'] = $username;

    $logOptions_id = $userID;
    $logOptions_uname = $username;
    $logOptions_uname = substr('' . $logOptions_uname . '', 0, 15); 
    ///////////          Update Last Login Date Field       /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$logOptions_id'"); 
    // Ready the output for this logged in user
    // Check if this user has any new PMs and construct which envelope to show
$sql_pm_check = mysql_query("SELECT id FROM private_messages WHERE to_id='$logOptions_id' AND opened='0' LIMIT 1");
$num_new_pm = mysql_num_rows($sql_pm_check);
if ($num_new_pm > 0) {
	$PM_envelope = '<a href="pm_inbox.php"><img src="../images/pm2.gif" width="18" height="11" alt="PM" /></a>';
} else {
	$PM_envelope = '<a href="pm_inbox.php"><img src="../images/pm1.gif" width="18" height="11" alt="PM" /></a>';
}
// Ready the output for this logged in user
     $logOptions = $PM_envelope . '    
 <a href="http://' . $dyn_www . '/profile.php?id=' . $logOptions_id . '">Profile</a>
   |  
<div class="dc">
<a href="#" onclick="return false">Account   <img src="../images/darr.gif" width="10" height="5" alt="Account Options" border="0"/></a>
<ul>
<li><a href="http://' . $dyn_www . '/edit_profile.php">Account Options</a></li>
<li><a href="http://' . $dyn_www . '/pm_inbox.php">Inbox Messages</a></li>
<li><a href="http://' . $dyn_www . '/pm_sentbox.php">Sent Messages</a></li>
</ul>
</div>

   |  
<a href="http://' . $dyn_www . '/logout.php">Log Out</a>';
}
?>

Link to comment
Share on other sites

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.