Jump to content

[SOLVED] session help.


jamesxg1

Recommended Posts

Afternoon peeps,

 

I have this error does anyone know why ?,

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\project\registertwo.php:1) in C:\xampp\htdocs\project\registertwo.php on line 1

 

Many thanks,

 

James.

Link to comment
Share on other sites

registertwo.php

 

<?php session_start();

include 'includes/commands.inc';

$add = new Command(); 
$add->MYSQLConnection();
$username = $_SESSION['username'];

if(isset($_POST['addnew'])) {
    
$add->AddEst($_POST['name'], $_POST['address'], $_POST['addresstwo'], $_POST['postcode'], 

$_POST['country'], $_POST['phone'], $_POST['county']);

}
?>
<!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=UTF-8">
<title>Register</title>
<link rel="stylesheet" type="text/css" href="core/css/view.css" media="all">
<script type="text/javascript" src="core/js/view.js"></script>

</head>
<body id="main_body" >

<img id="top" src="top.png" alt="">
<div id="form_container">

	<h1><a></a></h1>
<form id="addnew" class="appnitro"  method="post" action="">
				<div class="form_description">
		<h2><?php print $username; ?></h2>
		<p>This is your form description. Click here to edit.</p>
	</div>						
		<ul >

				<li id="li_1" >
	<label class="description" for="element_1">Name of establishment: 

</label>
	<div>
		<input id="name" name="name" class="element text medium" 

type="text" maxlength="255" value=""/> 

	</div><p class="guidelines" id="guide_1"><small>Please enter the valid 

and full name of your establishment.</small></p> 
	</li>		<li id="li_2" >
	<label class="description" for="element_2">Establishment phone Number: 

</label>
	<div>
		<input id="phone" name="phone" class="element text medium" 

type="text" maxlength="255" value=""/> 
	</div><p class="guidelines" id="guide_2"><small>Please enter a full and 

valid number.</small></p> 
	</li>		<li id="li_3" >
	<label class="description" for="element_3">Establishment address: 

</label>

	<div>
		<input id="address" name="address" class="element text large" 

value="" type="text">
		<label for="element_3_1">Street Address</label>
	</div>

	<div>
		<input id="addresstwo" name="addresstwo" class="element text 

large" value="" type="text">
		<label for="element_3_2">Address Line 2</label>
	</div>

	<div class="left">
		<select class="element text medium" id="county" name="county"> 
<?php

$resultt = mysql_query("SELECT * FROM `counties`") or die(mysql_error());

while($roww = mysql_fetch_assoc($resultt)) {

$dropdownn .= "<option value=" . $roww['county'] . ">" .$roww['county'] . "</option>";

}

echo $dropdownn;

?>
</select>
		<label for="element_3_3">City</label>
	</div>

	<div class="right">
		<input id="city" name="city" class="element text medium" value="" 

type="text">
		<label for="element_3_4">State / Province / Region</label>
	</div>

	<div class="left">
		<input id="postcode" name="postcode" class="element text medium" 

maxlength="15" value="" type="text">
		<label for="element_3_5">Postal / Zip Code</label>
	</div>

	<div class="right">
		<select class="element select medium" id="country" 

name="country"> 
<option value="Afghanistan" >Afghanistan</option>
<option value="Albania" >Albania</option>
<option value="Algeria" >Algeria</option>
<option value="Andorra" >Andorra</option>
<option value="Antigua and Barbuda" >Antigua and Barbuda</option>
<option value="Argentina" >Argentina</option>
<option value="Armenia" >Armenia</option>
<option value="Australia" >Australia</option>
<option value="Austria" >Austria</option>
<option value="Azerbaijan" >Azerbaijan</option>
<option value="Bahamas" >Bahamas</option>
<option value="Bahrain" >Bahrain</option>
<option value="Bangladesh" >Bangladesh</option>
<option value="Barbados" >Barbados</option>
<option value="Belarus" >Belarus</option>
<option value="Belgium" >Belgium</option>
<option value="Belize" >Belize</option>
<option value="Benin" >Benin</option>
<option value="Bhutan" >Bhutan</option>
<option value="Bolivia" >Bolivia</option>
<option value="Bosnia and Herzegovina" >Bosnia and Herzegovina</option>
<option value="Botswana" >Botswana</option>
<option value="Brazil" >Brazil</option>
<option value="Brunei" >Brunei</option>
<option value="Bulgaria" >Bulgaria</option>
<option value="Burkina Faso" >Burkina Faso</option>
<option value="Burundi" >Burundi</option>
<option value="Cambodia" >Cambodia</option>
<option value="Cameroon" >Cameroon</option>
<option value="Canada" >Canada</option>
<option value="Cape Verde" >Cape Verde</option>
<option value="Central African Republic" >Central African Republic</option>
<option value="Chad" >Chad</option>
<option value="Chile" >Chile</option>
<option value="China" >China</option>
<option value="Colombia" >Colombia</option>
<option value="Comoros" >Comoros</option>
<option value="Congo" >Congo</option>
<option value="Costa Rica" >Costa Rica</option>
<option value="Côte d'Ivoire" >Côte d'Ivoire</option>
<option value="Croatia" >Croatia</option>
<option value="Cuba" >Cuba</option>
<option value="Cyprus" >Cyprus</option>
<option value="Czech Republic" >Czech Republic</option>
<option value="Denmark" >Denmark</option>
<option value="Djibouti" >Djibouti</option>
<option value="Dominica" >Dominica</option>
<option value="Dominican Republic" >Dominican Republic</option>
<option value="East Timor" >East Timor</option>
<option value="Ecuador" >Ecuador</option>
<option value="Egypt" >Egypt</option>
<option value="El Salvador" >El Salvador</option>
<option value="Equatorial Guinea" >Equatorial Guinea</option>
<option value="Eritrea" >Eritrea</option>
<option value="Estonia" >Estonia</option>
<option value="Ethiopia" >Ethiopia</option>
<option value="Fiji" >Fiji</option>
<option value="Finland" >Finland</option>
<option value="France" >France</option>
<option value="Gabon" >Gabon</option>
<option value="Gambia" >Gambia</option>
<option value="Georgia" >Georgia</option>
<option value="Germany" >Germany</option>
<option value="Ghana" >Ghana</option>
<option value="Greece" >Greece</option>
<option value="Grenada" >Grenada</option>
<option value="Guatemala" >Guatemala</option>
<option value="Guinea" >Guinea</option>
<option value="Guinea-Bissau" >Guinea-Bissau</option>
<option value="Guyana" >Guyana</option>
<option value="Haiti" >Haiti</option>
<option value="Honduras" >Honduras</option>
<option value="Hong Kong" >Hong Kong</option>
<option value="Hungary" >Hungary</option>
<option value="Iceland" >Iceland</option>
<option value="India" >India</option>
<option value="Indonesia" >Indonesia</option>
<option value="Iran" >Iran</option>
<option value="Iraq" >Iraq</option>
<option value="Ireland" >Ireland</option>
<option value="Israel" >Israel</option>
<option value="Italy" >Italy</option>
<option value="Jamaica" >Jamaica</option>
<option value="Japan" >Japan</option>
<option value="Jordan" >Jordan</option>
<option value="Kazakhstan" >Kazakhstan</option>
<option value="Kenya" >Kenya</option>
<option value="Kiribati" >Kiribati</option>
<option value="North Korea" >North Korea</option>
<option value="South Korea" >South Korea</option>
<option value="Kuwait" >Kuwait</option>
<option value="Kyrgyzstan" >Kyrgyzstan</option>
<option value="Laos" >Laos</option>
<option value="Latvia" >Latvia</option>
<option value="Lebanon" >Lebanon</option>
<option value="Lesotho" >Lesotho</option>
<option value="Liberia" >Liberia</option>
<option value="Libya" >Libya</option>
<option value="Liechtenstein" >Liechtenstein</option>
<option value="Lithuania" >Lithuania</option>
<option value="Luxembourg" >Luxembourg</option>
<option value="Macedonia" >Macedonia</option>
<option value="Madagascar" >Madagascar</option>
<option value="Malawi" >Malawi</option>
<option value="Malaysia" >Malaysia</option>
<option value="Maldives" >Maldives</option>
<option value="Mali" >Mali</option>
<option value="Malta" >Malta</option>
<option value="Marshall Islands" >Marshall Islands</option>
<option value="Mauritania" >Mauritania</option>
<option value="Mauritius" >Mauritius</option>
<option value="Mexico" >Mexico</option>
<option value="Micronesia" >Micronesia</option>
<option value="Moldova" >Moldova</option>
<option value="Monaco" >Monaco</option>
<option value="Mongolia" >Mongolia</option>
<option value="Montenegro" >Montenegro</option>
<option value="Morocco" >Morocco</option>
<option value="Mozambique" >Mozambique</option>
<option value="Myanmar" >Myanmar</option>
<option value="Namibia" >Namibia</option>
<option value="Nauru" >Nauru</option>
<option value="Nepal" >Nepal</option>
<option value="Netherlands" >Netherlands</option>
<option value="New Zealand" >New Zealand</option>
<option value="Nicaragua" >Nicaragua</option>
<option value="Niger" >Niger</option>
<option value="Nigeria" >Nigeria</option>
<option value="Norway" >Norway</option>
<option value="Oman" >Oman</option>
<option value="Pakistan" >Pakistan</option>
<option value="Palau" >Palau</option>
<option value="Panama" >Panama</option>
<option value="Papua New Guinea" >Papua New Guinea</option>
<option value="Paraguay" >Paraguay</option>
<option value="Peru" >Peru</option>
<option value="Philippines" >Philippines</option>
<option value="Poland" >Poland</option>
<option value="Portugal" >Portugal</option>
<option value="Puerto Rico" >Puerto Rico</option>
<option value="Qatar" >Qatar</option>
<option value="Romania" >Romania</option>
<option value="Russia" >Russia</option>
<option value="Rwanda" >Rwanda</option>
<option value="Saint Kitts and Nevis" >Saint Kitts and Nevis</option>
<option value="Saint Lucia" >Saint Lucia</option>
<option value="Saint Vincent and the Grenadines" >Saint Vincent and the 

Grenadines</option>
<option value="Samoa" >Samoa</option>
<option value="San Marino" >San Marino</option>
<option value="Sao Tome and Principe" >Sao Tome and Principe</option>
<option value="Saudi Arabia" >Saudi Arabia</option>
<option value="Senegal" >Senegal</option>
<option value="Serbia and Montenegro" >Serbia and Montenegro</option>
<option value="Seychelles" >Seychelles</option>
<option value="Sierra Leone" >Sierra Leone</option>
<option value="Singapore" >Singapore</option>
<option value="Slovakia" >Slovakia</option>
<option value="Slovenia" >Slovenia</option>
<option value="Solomon Islands" >Solomon Islands</option>
<option value="Somalia" >Somalia</option>
<option value="South Africa" >South Africa</option>
<option value="Spain" >Spain</option>
<option value="Sri Lanka" >Sri Lanka</option>
<option value="Sudan" >Sudan</option>
<option value="Suriname" >Suriname</option>
<option value="Swaziland" >Swaziland</option>
<option value="Sweden" >Sweden</option>
<option value="Switzerland" >Switzerland</option>
<option value="Syria" >Syria</option>
<option value="Taiwan" >Taiwan</option>
<option value="Tajikistan" >Tajikistan</option>
<option value="Tanzania" >Tanzania</option>
<option value="Thailand" >Thailand</option>
<option value="Togo" >Togo</option>
<option value="Tonga" >Tonga</option>
<option value="Trinidad and Tobago" >Trinidad and Tobago</option>
<option value="Tunisia" >Tunisia</option>
<option value="Turkey" >Turkey</option>
<option value="Turkmenistan" >Turkmenistan</option>
<option value="Tuvalu" >Tuvalu</option>
<option value="Uganda" >Uganda</option>
<option value="Ukraine" >Ukraine</option>
<option value="United Arab Emirates" >United Arab Emirates</option>
<option value="United Kingdom" >United Kingdom</option>
<option value="United States" >United States</option>
<option value="Uruguay" >Uruguay</option>
<option value="Uzbekistan" >Uzbekistan</option>
<option value="Vanuatu" >Vanuatu</option>
<option value="Vatican City" >Vatican City</option>
<option value="Venezuela" >Venezuela</option>
<option value="Vietnam" >Vietnam</option>
<option value="Yemen" >Yemen</option>
<option value="Zambia" >Zambia</option>
<option value="Zimbabwe" >Zimbabwe</option>

		</select>
	<label for="element_3_6">Country</label>
</div><p class="guidelines" id="guide_3"><small>Please enter a full and valid 

address for your establishment.</small></p> 
	</li>

				<li class="buttons">
		    
			<input id="addnew" class="button_text" type="submit" 

name="submit" value="Submit" />
	</li>
		</ul>
	</form>	
	<div id="footer">

	</div>
</div>
<img id="bottom" src="bottom.png" alt="">

</body>
</html>

 

Controls.php

 

<?php 

  class Command {
            private $dbusername;
            private $dbpassword;
            private $dbhost;
            private $dbbase;
            private $lusername;
            private $lpassword;
            private $randid;
            private $aname;
            private $aadress;
            private $aadresstwo;
            private $apostcode;
            private $acountry;
            private $aphone;
            private $acounty;
            private $mfirstname;
            private $mlastname;
            private $musername;
            private $mpassword;
            private $memail;
            private $mphone;
            private $maddress;
            private $maddresstwo;
            private $mcity;
            private $mcounty;
            private $mpostcode;
            private $mcountry;
            private $sesid;
            private $sesuser;
            private $estid;
            private $tempuser;
            private $temppass;
            
            
      function __construct($dbusername = "root", $dbpassword = "", $dbhost = "localhost", 

$dbbase = "sli", $lusername = "none", $lpassword = "none", $randid = "mt_rand();", $aname 

= "none", $aaddress = "none", $aaddresstwo = "none", $apostocde = "none", $acountry = 

"none", $aphone = "none", $acounty = "none", $tempuser = "mt_rand();", $temppass = 

"mt_rand();") {
          
          $this->dbusername = $dbusername;
          $this->dbpassword = $dbpassword;
          $this->dbhost = $dbhost;
          $this->dbbase = $dbbase;
          $this->lusername = $lusername;
          $this->lpassowrd = $lpassword;
          $this->randid = mt_rand();
          $this->tempuser = $tempuser;
          $this->temppass = $temppass;

      }
                                          
      function MYSQLConnection() {
          
          $this->MYSQLConnect = mysql_connect($this->dbhost, $this->dbusername, 

$this->dbpassword);
          $this->SelectDB = mysql_select_db($this->dbbase, $this->MYSQLConnect) or 

die(mysql_error());
          
          return($this->SelectDB); 
      }
   
      function Login($lusername, $lpassword) {
          
          session_start();
                  
          $this->lusername = mysql_real_escape_string($lusername);
          $this->lpassword = mysql_real_escape_string(md5($lpassword));
          
          $this->LoginQ = "SELECT * FROM `members` WHERE username = '$this->lusername' 

AND password = '$this->lpassword'";
          $this->LoginR = mysql_query($this->LoginQ) or die (mysql_error());
              
          if(mysql_num_rows($this->LoginR) == '1') {
           
              while($fetch =  mysql_fetch_array($this->LoginR)) { 
                  
                  if($fetch['sus'] == '0') {

                            $_SESSION['username'] = $this->lusername;
                            $_SESSION['id'] = $fetch['id'];
                            $_SESSION['firstname'] = $fetch['firstname'];
                            $this->lid = $fetch['id'];
                                  header('Location: user_home.php');

                  }   else {
                      
                      echo ("Sorry but the account you are trying to access is suspended, 

Please try again.");
                      
                    exit();
                  }

              } 
                 

              echo "Sorry but the account you are trying to access is non existant, 

Please try again.";    
          }    
  }
  
      function Logout() {
        session_start();
        session_unset();
        session_destroy(); 

        header('Location: login.php'); 
    }
    
      function AddEst($aname, $aaddress, $aaddresstwo, $apostcode, $acountry, $aphone, 

$acounty) {

                   session_start();
                   
          $this->aname = mysql_real_escape_string($aname);
          $this->aaddress = mysql_real_escape_string($aaddress);
          $this->aaddresstwo = mysql_real_escape_string($aaddresstwo);
          $this->apostcode = mysql_real_escape_string($apostcode);
          $this->acountry = mysql_real_escape_string($acountry);
          $this->aphone = mysql_real_escape_string($aphone);
          $this->acounty = mysql_real_escape_string($acounty);
          $this->randid = mysql_real_escape_string(mt_rand());
          $this->aeusername = mysql_real_escape_string($_SESSION['username']);
          $this->aeid = mysql_real_escape_string($_SESSION['id']);

          
       mysql_query("INSERT INTO `establishments` (mid, username, id, name, address, 

addresstwo, postcode, county, phone, country) VALUES('$this->aeid', '$this->aeusername', 

'$this->randid', '$this->aname', '$this->aaddress', '$this->aaddresstwo', 

'$this->apostcode', '$this->acounty', '$this->aphone', '$this->acountry')") or 

die(mysql_error());
       $adddone = "Your establishment was succesfully added.";
       
       return $adddone;  
      }

      function SessionSecurity() {

if (!function_exists('session_regenerate_id')) {

            $tv = gettimeofday();
            $lcg['s1'] = $tv['sec'] ^ (~$tv['usec']);
            $lcg['s2'] = posix_getpid();

            $q = (int) ($lcg['s1'] / 53668);
            $lcg['s1'] = (int) (40014 * ($lcg['s1'] - 53668 * $q) - 12211 * $q);
            if ($lcg['s1'] < 0)
                $lcg['s1'] += 2147483563;

            $q = (int) ($lcg['s2'] / 52774);
            $lcg['s2'] = (int) (40692 * ($lcg['s2'] - 52774 * $q) - 3791 * $q);
            if ($lcg['s2'] < 0)
                $lcg['s2'] += 2147483399;

            $z = (int) ($lcg['s1'] - $lcg['s2']);
            if ($z < 1) {
                $z += 2147483562;
            }

            return $z * 4.656613e-10;
        }
     }

      function SessionRegen() {

            $tv = gettimeofday();
            $buf = sprintf("%.15s%ld%ld%0.8f", $_SERVER['REMOTE_ADDR'], $tv['sec'], 

$tv['usec'], $this->SessionSecurity() * 10);
            session_id(md5($buf));
                setcookie('PHPSESSID', session_id(), NULL, '/');
            return TRUE;
        }
       
      function SessionCheck() {
            
            if(isset($_SESSION['id']) && isset($_SESSION['username']) && 

isset($_SESSION['firstname'])) {
                
            } else {
                header('Location: login.php');
                exit();
            }
        }
        
      function AddMem($mfirstname, $mlastname, $musername, $mpassword, $memail, $mphone, 

$maddress, $maddresstwo, $mcity, $mcounty, $mpostcode, $mcountry) {
             
                                         session_start();
          
          $this->mfirstname = mysql_real_escape_string($mfirstname);
          $this->mlastname = mysql_real_escape_string($mlastname);
          $this->musername = mysql_real_escape_string($musername);
          $this->mpassword = mysql_real_escape_string(md5($mpassword));
          $this->memail = mysql_real_escape_string($memail);
          $this->mphone = mysql_real_escape_string($mphone);
          $this->maddress = mysql_real_escape_string($maddress);
          $this->maddresstwo = mysql_real_escape_string($maddresstwo);
          $this->mcity = mysql_real_escape_string($mcity);
          $this->mcounty = mysql_real_escape_string($mcounty);
          $this->mpostcode = mysql_real_escape_string($mpostcode);
          $this->mcountry = mysql_real_escape_string($mcountry);

        
                       $_SESSION['username'] = $this->musername;
                       $_SESSION['id'] = $this->randid;

            mysql_query("INSERT INTO `members` (id, firstname, lastname, email, phone, 

address, addresstwo, city, county, postcode, country, username, password, sus) 

VALUES('$this->randid', '$this->mfirstname', '$this->mlastname', '$this->memail', 

'$this->mphone', '$this->maddress', '$this->maddresstwo', '$this->mcity', 

'$this->mcounty', '$this->mpostcode', '$this->mcountry', '$this->musername', 

'$this->mpassword', '1')") or die(mysql_error());
             header('Location: registertwo.php');
             
        }

      function DelEst($estid) {
          
          $this->sesid = mysql_real_escape_string($_SESSION['id']);
          $this->sesuser = mysql_real_escape_string($_SESSION['username']);
          $this->estid = mysql_real_escape_string($estid);
          
          mysql_query("DELETE FROM `establishments` WHERE mid = '$this->sesid' AND 

username = '$this->sesuser' AND id = '$this->estid' LIMIT 1") or die(mysql_error());
          $deldone = "The establishment you selected was succesfully delete from our 

database.";
          return $deldone;
      }
      
    
  }

?>

 

Link to comment
Share on other sites

I have no clue how to find that lol,

 

And i have cleaned up command.inc a bit,

 

<?php 

  class Command {
            private $dbusername;
            private $dbpassword;
            private $dbhost;
            private $dbbase;
            private $lusername;
            private $lpassword;
            private $randid;
            private $aname;
            private $aadress;
            private $aadresstwo;
            private $apostcode;
            private $acountry;
            private $aphone;
            private $acounty;
            private $acity;
            private $mfirstname;
            private $mlastname;
            private $musername;
            private $mpassword;
            private $memail;
            private $mphone;
            private $maddress;
            private $maddresstwo;
            private $mcity;
            private $mcounty;
            private $mpostcode;
            private $mcountry;
            private $sesid;
            private $sesuser;
            private $estid;

            
            
      function __construct() {
          
          $this->randid = mt_rand();


      }
                                          
      function MYSQLConnection($dbusername = "root", $dbpassword = "", $dbhost = "localhost", $dbbase = "sli") {

          $this->dbusername = $dbusername;
          $this->dbpassword = $dbpassword;
          $this->dbhost = $dbhost;
          $this->dbbase = $dbbase;
          
          $this->MYSQLConnect = mysql_connect($this->dbhost, $this->dbusername, $this->dbpassword);
          $this->SelectDB = mysql_select_db($this->dbbase, $this->MYSQLConnect) or die(mysql_error());
          
          return($this->SelectDB); 
      }

      function AddEst($aname, $aphone, $aaddress, $aaddresstwo, $acounty, $acity, $apostcode, $acountry) {

                   session_start();
                   
          $this->aname = mysql_real_escape_string($aname);
          $this->aaddress = mysql_real_escape_string($aaddress);
          $this->aaddresstwo = mysql_real_escape_string($aaddresstwo);
          $this->apostcode = mysql_real_escape_string($apostcode);
          $this->acountry = mysql_real_escape_string($acountry);
          $this->aphone = mysql_real_escape_string($aphone);
          $this->acounty = mysql_real_escape_string($acounty);
          $this->acity = mysql_real_escape_string($acity);
          $this->randid = mysql_real_escape_string(mt_rand());
          $this->aeusername = mysql_real_escape_string($_SESSION['username']);
          $this->aeid = mysql_real_escape_string($_SESSION['id']);

          
       mysql_query("INSERT INTO `establishments` (mid, username, id, name, address, addresstwo, postcode, county, phone, country) VALUES('$this->aeid', '$this->aeusername', '$this->randid', '$this->aname', '$this->aaddress', '$this->aaddresstwo', '$this->apostcode', '$this->acounty', '$this->aphone', '$this->acountry', '$this->acity')") or die(mysql_error());
       $adddone = "Your establishment was succesfully added.";
       
       return $adddone;  
      }

function AddMem($mfirstname, $mlastname, $musername, $mpassword, $memail, $mphone, $maddress, $maddresstwo, $mcity, $mcounty, $mpostcode, $mcountry) {
             
                                         session_start();
          
          $this->mfirstname = mysql_real_escape_string($mfirstname);
          $this->mlastname = mysql_real_escape_string($mlastname);
          $this->musername = mysql_real_escape_string($musername);
          $this->mpassword = mysql_real_escape_string(md5($mpassword));
          $this->memail = mysql_real_escape_string($memail);
          $this->mphone = mysql_real_escape_string($mphone);
          $this->maddress = mysql_real_escape_string($maddress);
          $this->maddresstwo = mysql_real_escape_string($maddresstwo);
          $this->mcity = mysql_real_escape_string($mcity);
          $this->mcounty = mysql_real_escape_string($mcounty);
          $this->mpostcode = mysql_real_escape_string($mpostcode);
          $this->mcountry = mysql_real_escape_string($mcountry);

        
                       $_SESSION['username'] = $this->musername;
                       $_SESSION['id'] = $this->randid;

            mysql_query("INSERT INTO `members` (id, firstname, lastname, email, phone, address, addresstwo, city, county, postcode, country, username, password, sus) VALUES('$this->randid', '$this->mfirstname', '$this->mlastname', '$this->memail', '$this->mphone', '$this->maddress', '$this->maddresstwo', '$this->mcity', '$this->mcounty', '$this->mpostcode', '$this->mcountry', '$this->musername', '$this->mpassword', '1')") or die(mysql_error());
             header('Location: registertwo.php');
             
        }

      function Login($lusername, $lpassword) {
          
          session_start();
                  
          $this->lusername = $lusername;
          $this->lpassowrd = $lpassword;
          $this->lusername = mysql_real_escape_string($lusername);
          $this->lpassword = mysql_real_escape_string(md5($lpassword));
          
          $this->LoginQ = "SELECT * FROM `members` WHERE username = '$this->lusername' AND password = '$this->lpassword'";
          $this->LoginR = mysql_query($this->LoginQ) or die (mysql_error());
              
          if(mysql_num_rows($this->LoginR) == '1') {
           
              while($fetch =  mysql_fetch_array($this->LoginR)) { 
                  
                  if($fetch['sus'] == '0') {

                            $_SESSION['username'] = $this->lusername;
                            $_SESSION['id'] = $fetch['id'];
                            $_SESSION['firstname'] = $fetch['firstname'];
                            $this->lid = $fetch['id'];
                                  header('Location: user_home.php');

                  }   else {
                      
                      echo ("Sorry but the account you are trying to access is suspended, Please try again.");
                      
                    exit();
                  }

              } 
                 

              echo "Sorry but the account you are trying to access is non existant, Please try again.";    
          }    
  }
  
      function Logout() {
        session_start();
        session_unset();
        session_destroy(); 

        header('Location: login.php'); 
    }

      function SessionSecurity() {

if (!function_exists('session_regenerate_id')) {

            $tv = gettimeofday();
            $lcg['s1'] = $tv['sec'] ^ (~$tv['usec']);
            $lcg['s2'] = posix_getpid();

            $q = (int) ($lcg['s1'] / 53668);
            $lcg['s1'] = (int) (40014 * ($lcg['s1'] - 53668 * $q) - 12211 * $q);
            if ($lcg['s1'] < 0)
                $lcg['s1'] += 2147483563;

            $q = (int) ($lcg['s2'] / 52774);
            $lcg['s2'] = (int) (40692 * ($lcg['s2'] - 52774 * $q) - 3791 * $q);
            if ($lcg['s2'] < 0)
                $lcg['s2'] += 2147483399;

            $z = (int) ($lcg['s1'] - $lcg['s2']);
            if ($z < 1) {
                $z += 2147483562;
            }

            return $z * 4.656613e-10;
        }
     }

      function SessionRegen() {

            $tv = gettimeofday();
            $buf = sprintf("%.15s%ld%ld%0.8f", $_SERVER['REMOTE_ADDR'], $tv['sec'], $tv['usec'], $this->SessionSecurity() * 10);
            session_id(md5($buf));
                setcookie('PHPSESSID', session_id(), NULL, '/');
            return TRUE;
        }
       
      function SessionCheck() {
            
            if(isset($_SESSION['id']) && isset($_SESSION['username']) && isset($_SESSION['firstname'])) {
                
            } else {
                header('Location: login.php');
                exit();
            }
        }

      function DelEst($estid) {
          
          $this->sesid = mysql_real_escape_string($_SESSION['id']);
          $this->sesuser = mysql_real_escape_string($_SESSION['username']);
          $this->estid = mysql_real_escape_string($estid);
          
          mysql_query("DELETE FROM `establishments` WHERE mid = '$this->sesid' AND username = '$this->sesuser' AND id = '$this->estid' LIMIT 1") or die(mysql_error());
          $deldone = "The establishment you selected was succesfully delete from our database.";
          return $deldone;
      }
      
    
  }

?>

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.