473,320 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

fetch data from text box and compare on database for a log in page

1
Hello,
I am creating a log in page where the user enters the email and the password.
The app will check with the database if the user and the password are correct.
My issue is that when the php page retrieved the information on the text boxes, there is no data and therefore the user does not exist on the database.
The code is ass follows:

the index.php page is:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <meta charset="UTF-8">
  4.         <title>Pet Service Catalogue</title>
  5.     </head>
  6.     <body>
  7.         <h1 style="text-align:center;"><img src="cat's paw.jpg" width="150" height="150" alt="cat's paw"/> Welcome to Pet Service Catalogue</h1>
  8.         <p style="text-align:center;">Please enter your Log in Details:</p>
  9.  
  10.         <form style ="text-align:center;" method="POST" name="LogIN" action="log_in.php" enctype="multipart/form-data">
  11.             <p style="text-align:center;"> Email: <input type="text" name="user_email" value=""/></p>
  12.             <p style="text-align:center;"> Password: <input type="password" name="user_password" value="" /></p>
  13.             <input type="submit" value="Log In" name="LogIN" />
  14.         </form>
  15.         <form style="text-align:center;" name="registerprovider" action="registerprovider.php">
  16.             <p style="text-align:center;">Not Registered?:</p>
  17.             <input type="submit" value="Register Service Provider" name="Register Service Provider" />
  18.         </form>
  19.         <form style="text-align:center;" name="registerowner" action="registerowner.php">
  20.             <input type="submit" value="Register Pet Owner" name="Registerownerbutton" />
  21.         </form>
  22.     </body>
  23. </html>[COE]

the log_in.php page

Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <meta charset="UTF-8">
  4.         <title></title>
  5.     </head>
  6.     <body>
  7.  
  8.         <?php
  9. // Create connection
  10.         $con = mysqli_connect('localhost', 'root', 'root', 'PetServiceCatalogue') or die("Failed to connect to database:" . mysqli_error($con));
  11.  
  12.  
  13.         //Get user details and put them on varaiables
  14.         $user_email = mysqli_real_escape_string($con, $_POST['user_email']);
  15.         $user_password = mysqli_real_escape_string($con, $POST['user_password']);
  16.  
  17.         if (!empty($user_email) && !empty($user_password))
  18.         {
  19.         //look up for user details on the database
  20.         $query = "SELECT * FROM owner, provider WHERE email = '$user_email' AND password = SHA('$user_password') ";
  21.         $data = mysqli_query($con, $query);
  22.         $result = mysqli_num_rows($data);
  23.         printf("Number of rows %d \n", $result);
  24.         if ($result == 1) {
  25.             //The log in has found the user
  26.             $row = mysqli_fetch_array($data);
  27.             $user_email = $row('email');
  28.             $user_password = $row('password');
  29.             header("location: ownerhomepage.php");
  30.         } else {
  31.             //the user name or password are incorrect
  32.             echo "Wrong user email and password";
  33.         }
  34.         }
  35.         else
  36.         {
  37.  
  38.             echo ' You must enter the user email and user password';
  39.             ?>
  40.         <form name="back to index" action="index.php">
  41.             <input type="submit" value="Back to Log in page" name="Back to Log in page" /> </form>
  42.         <?php
  43.         }
  44.         mysqli_close($con);
  45.         ?>
  46.     </body>
  47. </html>
any help please
May 26 '14 #1
2 5415
Dormilich
8,658 Expert Mod 8TB
1) what does POST contain? (check with var_dump())

2) there are syntax errors on log_in.php:27/28

3) the location header won’t work.
May 27 '14 #2
kahan
1
hi,
on line 15 $_POST.
for location use header("Location: ownerhomepage.php");
thanks
Oct 15 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Hai Ly Hoang [MT00KSTN] | last post by:
I'm using Oracle 9i I drag OleDbDataAdapter from toolbox to create 'adapter' object. Click Generate Data Set on Property to create DataSet 'dataSet'. Drag DataGrid from toolbox to create dataGrid...
1
by: Siva | last post by:
Hi, I have a 3 tier ASP.Net app for a handheld which needs to fetch orders from database via a DAL and populate it in a gridview using objectdatasource. In the search page I have a few parameters...
2
by: hazelnut2705 | last post by:
Hi there.. how to fetch data from database and then display in title bar? <html <?php echo HTML_PARAMS; ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo...
2
by: anuragpj | last post by:
I had made a database table of a persons profile. now I want to show the data to the user in form of a editable html form so that the user can update his profile and database table should also be...
2
by: Ed | last post by:
Hope someone can help me out... I have been tasked to read some image data from an sql database and save the files to flat files. OK, sounds easy as I'v used BLOBs before. But this is an old...
1
by: viresh | last post by:
Hello everybody, I am quite beginner as a software professional in php & mysql. I want to know how I can fetch data from mysql database to show in a form's drop down box with php...
4
by: sssk28 | last post by:
i have written a jsp code which fetches data from mysql database. it performs insertion operation correctly but it fails while fetching the data. i am getting error on line which contains...
4
by: Ankur1202 | last post by:
i want to fetch data from gridview.i have fetched the data from database on gridview. now i have data on gridview. now i don't want to hit the database. i want to fetch the data from gridview. what...
4
by: vishal prada | last post by:
there is one registration form where using dropdown box i select one country and it save into mysql database. now i want to fetch that value of mysql database table into edit profile form where i...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.