Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Problem in PHP login Code plz help
Old 10-08-2010, 03:46 AM Problem in PHP login Code plz help
Banned

Posts: 408
Name: mushget
Trades: 0
Login

<form method="post" action="../include/loginsession.php" name="saveform">
<div>
Username or Email <br /><input type="text" name="emailadd" size="25" value="" />

Password<br /><input type="password" name="userpassword" size="25" value=""/>

<center><br /><input name="userlogin" type="button" value="LOGIN"/></center>
</div>




/////////////////////loginsession.php//////////////////////////


<?php
ob_start();
session_start();

//check that the user is calling the page from the login form and not accessing it directly



if (!isset($emailadd) || !isset($userpassword))
{
header( "Location: ../index.php" );
}
//check that the form fields are not empty, and redirect back to the login page if they are

elseif (empty($emailadd) || empty($userpassword))
{
header( "Location: ../index.php" );
}
else
{

//convert the field values to simple variables


$emailadd = addslashes($_POST['emailadd']);
$pass =addslashes($_POST['userpassword']);


//set the database connection,, connection is working fine

include("connection.php");

$result=mysql_query("select * from userregisteration where email='$emailadd' AND password='$pass'", $connection);


//check that at least one row was returned

$rowCheck = mysql_num_rows($result);


if($rowCheck > 0)
{
//while($row = mysql_fetch_array($result))
{
//start the session and register a variable
session_register('emailadd');

//successful login code will go here...s

header( "Location: ../discoverquestion/discoverquestion.php" );

}

}
else {

//if nothing is returned by the query, unsuccessful login code

//echo 'Incorrect login name or password. Please try again.';
header( "Location: ../index.php" );

}
}
?>
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
 
Register now for full access!
Old 10-08-2010, 03:39 PM Re: Problem in PHP login Code plz help
spyderwebtech's Avatar
Skilled Talker

Posts: 51
Trades: 0
Quote:
Originally Posted by mushget View Post
Login


if (!isset($emailadd) || !isset($userpassword))
{
header( "Location: ../index.php" );
}
//check that the form fields are not empty, and redirect back to the login page if they are

elseif (empty($emailadd) || empty($userpassword))
{
header( "Location: ../index.php" );
}
else
{

//convert the field values to simple variables


$emailadd = addslashes($_POST['emailadd']);
$pass =addslashes($_POST['userpassword']);


You are checking for $emailadd and $userpassword before you set them from the $_POST array.... your code is redirecting before the database insert.
spyderwebtech is offline
Reply With Quote
View Public Profile
 
Old 10-11-2010, 08:54 PM Re: Problem in PHP login Code plz help
Banned

Posts: 408
Name: mushget
Trades: 0
Thanks guys.
mushget is offline
Reply With Quote
View Public Profile Visit mushget's homepage!
 
Reply     « Reply to Problem in PHP login Code plz help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.53342 seconds with 12 queries