Jump to content

Send to URL From database


cfgcjm

Recommended Posts

I have a log in script which currently sends all users, globally, to a url upon successful login. What i would like to do is have each user sent to a different url which is specified in the same database as their username & Password. I suppose my question is how do i read/save this field url to a variable and then send the user to that url. Here is my code:

 

<?php
/* Login Script */
require ('mysql.php');
session_start();

if (isset ($_POST['submit'])) { // Check to see if the form has been submitted
$username = $_POST['username'];
$password = $_POST['password']; 
									  

// See if the user exists
$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
if ($r = mysql_query ($sql)) {
	$row = mysql_fetch_array ($r);
	$num = mysql_num_rows ($r);

	if ($num > 0) { // if there is a row with that username/password, the user exists
		// Now we can assign some SESSIONS, so we can verify on later pages that the user is "logged in"
		$_SESSION['users_id'] = $row['users_id'];
		$_SESSION['username'] = $row['username'];
		$_SESSION['loggedin'] = TRUE; // This is where we will check to see if the user is logged in
		header("Location:http://www.digiconmediagroup.com/login/yes.php");
		exit;

	} else {
		// User does not exist

		header("location:http://www.digiconmediagroup.com/login/index.php");
		exit;
	}
} else {
	// The query failed
	print 'Error:' . mysql_error(); // print the MySQL error
}
} else { // The form was not submitted
// Display the form
print'    <div id="outer">
    <form method="post" action="index.php">
	<table style="width: 328px; height: 160px" cellspacing="0" cellpadding="0">
		<tr>
			<td style="width: 147px; height: 53px"></td>
			<td style="width: 164px; height: 53px"></td>
		</tr>
		<tr>
			<td style="height: 35px; width: 147px" class="login">USERNAME:</td>
			<td style="height: 35px; width: 164px" class="style1">
			  
			<input name="username" type="text" style="width: 95px" /> </td>
		</tr>
		<tr>
			<td style="height: 35px; width: 147px" class="login">PASSWORD:</td>
			<td style="height: 35px; width: 164px" class="style1">
			  
			<input name="password" type="password" style="width: 95px" /> </td>
		</tr>
		<tr>
			<td style="height: 47px; width: 147px"></td>
			<td style="height: 47px; width: 164px" valign="top" class="style1">
			  
			<input name="submit" type="submit" value="submit" /> </td>
		</tr>
	</table>
</form>
    </div>';
}
?>
<style type="text/css" media="all">
<!--
@import url(http://www.digiconmediagroup.com/market.css);
-->
	a:link {color:black;text-decoration:none;}
	a:visited {color:purple;text-decoration:none;}
	a:hover {color:#0066CC;text-decoration:underline;}
	a:active {color:#FF6600;text-decoration:underline;}

.style1 {
text-align: left;
}

</style>

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.