Jump to content

Recommended Posts

Hi Guys.

 

I'm trying to register a session, but I just can't seem to get it to work.

Can you please help me find the fault.

 

Thanks for any help

 

<?PHP
session_start();
include("dbconnect.php");


$arrErrors = array();

if (!empty($_POST['submit'])) {

if ($_POST['Pword']==''){
$arrErrors['Pword'] = 'Add Your Password';
$star1 = '*';
}
if ($_POST['email']==''){
$arrErrors['email'] = 'Add Your Email';
$star2 = '*';
}

if (count($arrErrors) == 0) {

	$password1=$_POST['Pword'];
	$email1=$_POST['email'];


	$sql="SELECT * FROM awards_register WHERE email='$email1' && Pword='$password1'";
	$result = mysql_query($sql);
	$count = mysql_num_rows($result);
	$row = mysql_fetch_array($result);
        $reg_id = $row['reg_id'];

if($count==1){

session_register("reg_id");
echo $_SESSION['reg_id'];


//header("Location:rewards_members.php");
} else {
$noinput = '<div class="warning">Your details are incorrect<br>Please try again</div>';
}


} else {
if (empty($password1) || empty($email1)) {  
$strError = '<div class="warning">ERROR<br></div><div class="boxTitle">'; 
foreach ($arrErrors as $error) {
$strError .= "<li>$error</li>";
}
$strError .= '</div>';
}
}		


}
?>

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Untitled Document</title>
</head>

<body>
   <?PHP 
if ($strError){
echo $strError;
}
if ($noinput){
echo '<br>'.$noinput;
}
echo '<br>
<form action="'.$PHP_SELF.'" method="post" name="form1">
  <table width="200" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td height="25">Email: </td>
      <td height="25"><input name="email" type="text" size="15"  value="'.$_POST['email'].'"/></td>
      <td height="25"><span class="smallOrange">'.$star2.'</span></td>
    </tr>
    <tr>
      <td width="90" height="25">Password: </td>
      <td width="90" height="25"><input name="Pword" type="text" size="15" value="'.$_POST['Pword'].'" /></td>
      <td width="20" height="25"><span class="smallOrange">'.$star1.'</span></td>
    </tr>
    <tr>
      <td height="30" colspan="3" align="center"><input type="submit" class="smallOrange" name="submit" value="Login" /></td>
      </tr>
  </table>
</form>
';

?>
</body>
</html>

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/105676-solved-sessions-help-please/
Share on other sites

change

<?php
session_register("reg_id");
echo $_SESSION['reg_id'];
?>

to

<?php
$_SESSION['reg_id'] = $reg_id;
echo $_SESSION['reg_id'];
?>

 

if you script use session_register(), it will not work in environments where the PHP directive register_globals is disabled.

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.