Jump to content

[SOLVED] session help easy one cheers.


redarrow

Recommended Posts

 

I can not seem to understand how to get the session, To work with the secure number.

 

if the user put the correct number in then i need it to hold the session,

and keep it in place, off the secret number form.

 

 

 

secure login.

<?php session_start();

if(isset($_POST['submit'])){

if(preg_match('/\.php\?/', $_SERVER['REQUEST_URI']))
{
	exit('Did you no, It a offence to try and hack someone\'s web site!/<br>
           I have recorded your ip, and other computer informmation, to pass on 
           to the correct crime busters!');
}

$secret_number=trim($_POST['number1'])
.trim($_POST['number2']).trim($_POST['number3']).trim($_POST['number4']);

$username=$_POST['username'];
$password=$_POST['password'];

if(!preg_match("/^[a-z]{4}[0-9]{4}[a-z]{4}$/i",$username)){

	echo "<font color='red'>(Please enter the correct username format please!
      <br><b><font color='blue'>4 letter 4 numbers and 4 letters.)
      </font></b><br><br>";
}
if(!preg_match("/^[a-z]{4}[0-9]{4}$/i",$password)){

	echo "<font color='red'>(Please enter the correct password format please!
      <br><b><font color='blue'>4 letter 4 numbers.)
      </font></b><br><br>";
}

if(preg_match("/^[0]{4}$/",$secret_number)){

	echo "<font color='red'>(Please enter the correct secret number as provided!
      <br><b><font color='blue'>4 mixed numbers.)
      </font></b><br><br>";
}

if($secret_number==0000){
	$warning[1]="Please enter your correct number!";
	$secret_number=$warning[1];
}


if(empty($username)){
	$warning[2]="please enter correct username!";
}

if(empty($password)){
	$warning[3]="please enter correct password!";
}

if(!$warning[3])	{
	$_SESSION['password']=$password;
}elseif($warning[3]){
	unset($_SESSION['password']);
}


if(!$warning[2])	{
	$_SESSION['username']=$username;
}elseif($warning[2]){
	unset($_SESSION['username']);
}

if($username && $password && $secret_number){

	echo"My secret number is:\n  $secret_number <br> My username is: $username\n <br> My password is $password\n";
}
}

if(isset($_POST['reset'])){

unset($_SESSION['username']);
unset($_SESSIOn['password']);
session_destroy();

header("location: {$_SERVER['PHP_SELF']}");
}

//Post form to it self
$php_self=$_SERVER['PHP_SELF'];

//Username and password form.
echo <<<form_data

<form method="POST" action="$php_self">
<p></p>
form_data;
if($warning[2]){
echo "<b><font color='red'>{$warning[2]}</font></b> <br>";
}else{
echo"<b>Username:</b>\n";
}
echo <<<form_data1
<br>
<input type="text" name="username" value="{$_SESSION['username']}">
<p></p>
form_data1;
if($warning[3]){
echo "<b><font color='red'>{$warning[3]}</font></b> <br>";
}else{
echo"<b>Password:</b>\n";
}
echo <<<form_data2
<br>
<input type="password" name="password" value='{$_SESSION['password']}'>
<p></p>
form_data2;

if($warning[1]){

echo "<b><font color='red'>{$warning[1]}</font></b> <br><br>";
}else{
echo"<b>Secret Number:<br>\n";
}
echo "<select name='number1'>";

for($i1=0; $i1<11; $i1++){
echo"<option value='$i1'>$i1</option>";
}
echo"</select>";

echo "<select name='number2'>";
for($i2=0; $i2<11; $i2++){
echo"<option value='$i2'>$i2</option>";
}
echo"</select>";

echo "<select name='number3'>";
for($i3=0; $i3<11; $i3++){
echo"<option value='$i3'>$i3</option>";
}
echo"</select>";

echo "<select name='number4'>";
for($i4=0; $i4<11; $i4++){
echo"<option value='$i4'>$i4</option>";
}
echo"</select>";

echo <<<form_continue1
<p></p>
<input type="submit" name="submit" value="SEND!">
<input type="submit" name="reset" value="Reset Form">
</form>

form_continue1;

?>

Link to comment
https://forums.phpfreaks.com/topic/144456-solved-session-help-easy-one-cheers/
Share on other sites

solved it, yee haaaa

 

you can test the log in it grate.

http://simpleforum.ath.cx/login_script/login.php

 

username must be  4 letters, 4 numbers, and 4 letters, agin.

 

password must be 4 letters and 4 numbers.

 

secret number can be any number except it default.

 

I have used sessions on all the form info, so you can see what your doing or getting wrong.

 

 

Also anybody put a ? at the end off the .php there get a error message.

 

thanks everybody for your help.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.