what i want from here http://kosilice.ba/suad.php log in on this page display other data on
http://kosilice.ba/suad%20-%20Copy.php
use session
Please post the codes on here. We aren’t mind readers who can see your code from inside your server.
<?Php session_start();?>
<?php
if (isset($_POST['Submit1'])) {
$conn= mysqli_connect("");
if(mysqli_connect_error()) {
die('Could not connect: ' . mysqli_connect_error());
}
if (!$conn->select_db("")) {
echo "Could not select database";
exit();
}
$options = array("cost"=>4);
$hashPassword = password_hash($password,PASSWORD_BCRYPT,$options);
$email= trim($_POST['email']);
$password = trim($_POST['password']);
$sql = "select first_name,email,password from users where email = '".$email."'";
$rs = mysqli_query($conn,$sql);
$numRows = mysqli_num_rows($rs);
if($numRows == 1){
$row = mysqli_fetch_assoc($rs);
if(password_verify($password,$row['password']))
{
$_SESSION["user_id"] =$email;
$_SESSION["first_name"] =$first_name;
echo'<script>1</script>';
}
else{
echo'<script>11</script>';
}
}
$conn->close();
?>
</td>
</tr>
</tbody>
</table>
</div>
<div class="wrapper">
<div style="witdh: 100%; ">
<div class="htitel"><h2 class="fl" style="border:0; margin:0;">Customer Details</h2></div>
<!-- start of search row -->
<div class="container-fluid" style="margin:0; padding:0;">
<div class="row-fluid" style="background-color: #faac59; padding: 1% 0">
<div class="span12">
<h3 style="margin-left:2.3%"><DIV align="left">Existing Customer? </div></h3></br>
<form class="form-horizontal" action="" method="post" id="form1" style="width: 95%; margin: 0 2.5%" novalidate>
<div class="control-group">
<label class="control-label" for="ea">Email Address:</label>
<div class="controls">
<DIV align="left"> <span id="sprytextfield18"><span id="sprytextfield19">
<input type="text" name="email" id="email"> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>
<span class="textfieldRequiredMsg">A value is required.</span></span>
<span class="textfieldRequiredMsg">A value is required.</span></span></div>
</div> <span class="textfieldRequiredMsg">A value is required.</span></span></td>
</br>
</div>
<div class="control-group">
<label class="control-label" for="pa">Password:</label>
<div class="controls">
<DIV align="left"><span id="sprytextfield15">
<input type="text" name="password" id="password" class="input-large valid">
<span class="textfieldRequiredMsg">A value is required.</span></span></div>
</div> <span class="textfieldRequiredMsg">A value is required.</span></span></td>
</div>
<div class="control-group">
<div class="controls" id="exist_wait"></div>
</div>
<div class="control-group">
<label class="control-label"></label>
<div class="controls">
<tr valign="baseline">
<td nowrap align="right"> </td>
<td> <DIV align="left"><input type="submit" name="Submit1" class="submit" value="Submit"></div></td>
</tr>
</form>
second pag
e |echo 'Welcome' ?> <?php echo |$_SESSION["email"] . "<br>" ;//Output the session username |
|---|---|
|echo 'Welcome' ?> <?php echo |$_SESSION["first_name"]. "<br>" ;//Output the session username |
|echo 'Welcome' ?> <?php echo |$_SESSION["Last_name"]. "<br>" ;//Output the session username |
|echo 'Welcome' ?> <?php echo |$_SESSION["first_name"] . "<br>";//Output the session username |
|echo 'Welcome' ?> <?php echo |$_SESSION["password"] . "<br>";//Output the session username|
t`
to login use
email
sam@hotmail.com
and pass
sam
That better not be your password for your attempted login system. I strongly suggest you look into learning the basics first. A login system is a complex system that a beginner will never get right. It’s not just about making the login system work. It’s also about making it secure. You have to start adding a bunch security on top of it which I highly doubt you understand which ones to implement.
But I know you’re going to ignore the suggestion so I’ll just ask one question. Can you please reformat the 2nd post because nothing in there makes any sense.
So i need fetch data from db based on email and password
You also need to fix a number of HTML errors on that page.
That’s not what I asked you to do. I asked you to reformat the 2nd post you did so that I can see what’s going on. I didn’t ask you to tell me what you want it to do. Please start listening to people.
Instead of your form submit going back to the same page, running the validation, setting some session variables and then redirecting to the next page, why not have the form go straight to the next page, and do the validation in there?
same thing
In your code here, you only set two of the session variables, not all the ones you want to display. One of them is set to a value you haven’t defined anywhere. Then you don’t do the redirect to the second page, you just put a couple of numbers inside <script> tags.
redirect works on local perfect but wont on live
which i didnt define
Where does $first_name come from?
from db
Not in the code you posted.
i am trying like this on first page
if($numRows == 1){
$row = mysqli_fetch_assoc($rs);
if(password_verify($password,$row['password']))
{
echo'<script>
window.location.href = "http://kosilice.ba/suad%20-%20Copy.php";
</script> ';
{
$first_name = trim($row['first_name']);
$first_name = ($row['first_name']);
$row['first_name'] =$first_name;
second page
$email= trim($_POST['email']);
$password = trim($_POST['password']);
$sql = "select email,password from users where email = '".$email."'";
$rs = mysqli_query($conn,$sql);
$numRows = mysqli_num_rows($rs);
if($numRows == 1){
$row = mysqli_fetch_assoc($rs);
if(password_verify($password,$row['password']))
{
$_SESSION['first_name'] =$first_name;
echo 'Welcome' ?> <?php echo $row['first_name'] . "<br>" ;/
/Output the session username
getting
Warning : mysqli_query() expects parameter 1 to be mysqli, null given in /home/kosilice/public_html/suad - Copy.php on line 69
Warning : mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/kosilice/public_html/suad - Copy.php on line 70
OK, but that’s totally different to the code you posted above. It’s impossible to provide any meaningful help if you don’t show the code. Can you add code tags as well, please, it’s hard to read as it is.