logging in and signing up
On my signin page users can sign up, then they are transfered to a restricted access page just for logged in users. problem is after signing up they have to login as well to get the the restricted page. im sure i have a session error im just not sure how to fix it. how do i log users in at the same time that they sign up for the first time?
<?php require_once('Connections/signIn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "signUp")) {
$insertSQL = sprintf("INSERT INTO userdata (userName, userPassword, name, eMail) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['username'], "text"),
GetSQLValueString($_POST['password'], "text"),
GetSQLValueString($_POST['name'], "text"),
GetSQLValueString($_POST['eMail'], "text"));
mysql_select_db($database_signIn, $signIn);
$Result1 = mysql_query($insertSQL, $signIn) or die(mysql_error());
$insertGoTo = "upload.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="C:\DBA\Templates\master.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Sign Up</title>
<style type="text/css">
<!--
#container #mainContent #form .table tr th #Sign Up {
text-align: center;
}
-->
</style>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationConfirm.js" type="text/javascript"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationConfirm.css" rel="stylesheet" type="text/css" />
<!-- InstanceEndEditable -->
<style type="text/css">
<!--
@import url("styles/main.css");
-->
</style>
</head>
<body>
<div id="container">
<div id="header"><img src="images/top banner.jpg" width="967" height="110" alt="Deaf Boyz Audio - Way too loud..." /></div>
<!-- InstanceBeginEditable name="mainContent" -->
<div id="mainContent">
<div id="headerDiv"><h1>Sign Up</h1></div>
<div id="textDiv">
<p>Got a system that needs to be recognized?</p>
<p>Join DeafBoyzAudio.com</p>
<p> for a chance to show off what you got...</p>
<p>Put in your name, e-mail, and pick a username</p>
<p> and password to start uploading.</p>
<p>User login info will be sent to your email if you ever lose it</p>
<p>so make sure its right...</p>
<p>Don't worry, we hate spam too. </p>
</div>
<form action="<?php echo $editFormAction; ?>" method="POST" name="signUp" class="signUp" id="signUp">
<table width="280" border="0" align="center" cellpadding="1" cellspacing="3" class="table">
<tr>
<td width="85" align="center" scope="row">Name:</td>
<td width="182" align="left"><span id="sprytextfield1">
<label for="name"></label>
<input name="name" type="text" id="name" tabindex="10" size="30" maxlength="30" />
<span class="textfieldRequiredMsg">Name Required</span></span></td>
</tr>
<tr>
<td width="85" align="center" scope="row">E-Mail:</td>
<td align="left">
<label for="eMail"></label>
<span id="sprytextfield2">
<label for="eMail2"></label>
<input name="eMail" type="text" id="eMail2" tabindex="20" size="30" maxlength="40" />
<span class="textfieldRequiredMsg">E-mail Required</span></span></td>
</tr>
<tr>
<td width="85" align="center" scope="row">Username:</td>
<td align="left">
<label for="username"></label>
<span id="sprytextfield3">
<label for="username2"></label>
<input name="username" type="text" id="username2" tabindex="30" size="30" maxlength="30" />
<span class="textfieldRequiredMsg">Username Required</span></span></td>
</tr>
<tr>
<td width="85" align="center" scope="row">Password:</td>
<td>
<label for="password"></label>
<span id="sprytextfield4">
<label for="password3"></label>
<input name="password" type="password" id="password3" tabindex="40" size="30" maxlength="30" />
<span class="textfieldRequiredMsg">Password Required</span></span></td>
</tr>
<tr>
<td align="center" scope="row">Confirm:</td>
<td scope="row">
<label for="confirm"></label>
<span id="spryconfirm1">
<label for="confirm2"></label>
<input name="confirm" type="password" id="confirm2" tabindex="50" size="30" maxlength="30" />
<span class="confirmRequiredMsg">Please Confirm Password</span><span class="confirmInvalidMsg">Passwords Don't Match</span></span></td>
</tr>
<tr>
<th colspan="2" scope="row"><input type="submit" name="Sign Up" id="Sign Up" value="Sign Up " /></th>
</tr>
</table>
<input type="hidden" name="MM_insert" value="signUp" />
</form>
</div>
<!--
//-->
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {validateOn:["blur", "change"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur", "change"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur", "change"]});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {validateOn:["blur", "change"]});
var spryconfirm1 = new Spry.Widget.ValidationConfirm("spryconfirm1", "password3", {validateOn:["blur", "change"]});
//-->
</script>
<!-- InstanceEndEditable -->
<div id="sidebar">
<p class="sidebarLink"><a href="index.htm">home</a></p>
<p class="sidebarLink"><a href="pics.htm">pics</a></p>
<p class="sidebarLink"><a href="video.htm">video</a></p>
<p class="sidebarLink"><a href="login.php">upload</a></p>
<p class="sidebarLink"><a href="about.htm">about</a></p>
<p class="sidebarLink"><a href="feedback.php">feedback</a></p>
</div>
<div id="footer">
<h6 class="copyright">Copyright Deaf Boyz Audio, 2009</h6>
</div>
</div>
</body>
<!-- InstanceEnd --></html>