| | |
PHP login/password script
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
Can someone recommend a good, reliable open source PHP script that allows for a user to login with a username and password/id.
I want to allow a user to enter his/her username and password, where the password pulls specific data from the database, such as all the data with a certain store number - such that a manager could access all the information for each one of their different stores.
In this script, I have it so a customer can access his or her specific information about their product order. But where I'm stuck is incorporating a separate login/password form where the password pulls all the data that has a particular number. Do I still use the $_POST function if I'm pulling large sections of data?
Thanks for any help, as always.
I want to allow a user to enter his/her username and password, where the password pulls specific data from the database, such as all the data with a certain store number - such that a manager could access all the information for each one of their different stores.
<?php
if(isset($_POST['submit'])) {
$jobnumber=$_POST['jobnumber'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$query = "SELECT * FROM customers WHERE job_number='$jobnumber' OR email='$jobnumber'";
$result = mysql_query($query);In this script, I have it so a customer can access his or her specific information about their product order. But where I'm stuck is incorporating a separate login/password form where the password pulls all the data that has a particular number. Do I still use the $_POST function if I'm pulling large sections of data?
Thanks for any help, as always.
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
I've tried this method:
But I'm getting this error:
Notice: Undefined index: store_id in /Users/laurenyoung/Sites/parsec/sox.php on line 103
Line 103 = $storeid=$_POST['store_id'];
if(isset($_POST['submit'])) {
$storeid=$_POST['store_id'];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$query = "SELECT * FROM retailers WHERE store_id='$storeid'";
$result = mysql_query($query);
echo "<table class='sample'>";
while ($row = mysql_fetch_array($result)) {But I'm getting this error:
Notice: Undefined index: store_id in /Users/laurenyoung/Sites/parsec/sox.php on line 103
Line 103 = $storeid=$_POST['store_id'];
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
I don't think I explained myself right.
What I'm trying to do is allow for multiple users (managers from various stores) the ability to access their store information by typing in a identification number. All the information, from all the different stores, would be within 1 single database.
If a manager with an ID 7200 types in 7200 they will receive all the information from the database with the ID 7200.
I don't think my code above will work.
Thanks again for any help.
What I'm trying to do is allow for multiple users (managers from various stores) the ability to access their store information by typing in a identification number. All the information, from all the different stores, would be within 1 single database.
If a manager with an ID 7200 types in 7200 they will receive all the information from the database with the ID 7200.
I don't think my code above will work.
Thanks again for any help.
•
•
Join Date: Dec 2007
Posts: 252
Reputation:
Solved Threads: 27
will the user be able to access other pages to display more information?
if this is the case you can set the id into a session. also with letting the users know this number and depending on the information stored this could a security risk.?
could have the user login and when they login have a field in the db storing the storeid. on login set that store id into a session.
example:
then when you need to pull info for the user to view you can use this in your query
but this is just an idea
if this is the case you can set the id into a session. also with letting the users know this number and depending on the information stored this could a security risk.?
could have the user login and when they login have a field in the db storing the storeid. on login set that store id into a session.
example:
php Syntax (Toggle Plain Text)
if(isset($_POST['login'])){ $query = mysql_query("SELECT * FROM users WHERE UserName = '".$_POST['username']."' and Password='".md5($_POST['pass'])."'")or die(mysql_error()); $info=mysql_fetch_array($query); $_SESSION['store_ref']=$info['store_id'];
then when you need to pull info for the user to view you can use this in your query
php Syntax (Toggle Plain Text)
$viewinfo = mysql_query("SELECT * FROM table WHERE store_id = '".$_SESSION['store_ref']."'") or die(mysql_error()); //display info while($row=mysql_fetch_assoc($viewinfo)){ echo $row['datacolumn']; }
but this is just an idea
Last edited by ProfessorPC; May 28th, 2008 at 9:33 am.
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
I will have the user login to have access to a page with a simple form asking for a Store ID.
When the manager puts in his/her Store ID, all the Store ID's with that number will be pulled from the database.
So I guess the problem is more simple than I've realized. All I want is a script that will pull multiple rows from a table in the database, instead of just one. This code below pulls a single row from a table in the database:
It pulls the row with that job number. What I need is something that will pull ALL the rows with that job number, which could be several hundreds. Could this work?
Thanks!
When the manager puts in his/her Store ID, all the Store ID's with that number will be pulled from the database.
So I guess the problem is more simple than I've realized. All I want is a script that will pull multiple rows from a table in the database, instead of just one. This code below pulls a single row from a table in the database:
PHP Syntax (Toggle Plain Text)
if(isset($_POST['submit'])) { $jobnumber=$_POST['jobnumber']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("", $con); $query = "SELECT * FROM customers WHERE job_number='$jobnumber' OR email='$jobnumber'"; $result = mysql_query($query);
It pulls the row with that job number. What I need is something that will pull ALL the rows with that job number, which could be several hundreds. Could this work?
$viewinfo = mysql_query("SELECT * FROM retailers WHERE store_id = 'store_id'".$_SESSION['store_ref']."'") or die(mysql_error());
//display info
while($row=mysql_fetch_assoc($viewinfo)){
echo $row['datacolumn'];
}Thanks!
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
I don't understand why I'm getting an "undefined index error" here??? on line 5 which is:
PHP Syntax (Toggle Plain Text)
$id=$_POST['store_id'];
<?php
if(isset($_POST['submit'])) {
$id=$_POST['store_id'];
$con = mysql_connect("localhost","root","//");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("//", $con);
$query = "SELECT * FROM retailers WHERE store_id='$id' ";
$result = mysql_query($query);
echo "<table class='sample'>";
while ($row = mysql_fetch_array($result)) {
//store id
echo "<th>Store ID</th>";
echo "<td>" . $row['store_id'] . "</td>";
echo "</tr>";
//name
echo "<th>Customer Name</th>";
echo "<td>" . $row['name'] ."</td>";
echo "</tr>";
//email
echo "<th>Email</th>";
echo "<td>".$row['email']."</td>";
echo "</tr>";
//repair number
echo "<th>Repair Number</th>";
echo "<td>".$row['repair_number']."</td>";
echo "</tr>";
//in date
echo "<th>In Date</th>";
echo "<td>".$row['in_date']."</td>";
echo "</tr>";
//est date
echo "<th>Estimated Date</th>";
echo "<td>".$row['est_date']."</td>";
echo "</tr>";
}
echo "</table>";
}
?> Last edited by justinmyoung; May 28th, 2008 at 4:34 pm.
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
<?php
$con = mysql_connect("localhost","root","//");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("parsec", $con);
echo $_POST['store_id'];
?>did I do that correctly? It tells me I have an UNDEFINED INDEX ERROR
Could that be something to do with how it is entered in the database?
Thanks!
•
•
Join Date: Mar 2008
Posts: 129
Reputation:
Solved Threads: 0
Here's the first page (b.php), which is a simple input form:
Here's the second page (sox.php), which I would like to display the results:
Theoretically, I would like to have the fields displayed horizontally rather than vertically, but that's something else of a battle.
Thanks!
<html> <body> <h1>Sample</h1> <div id="container"> <h2></h2> <form action="sox.php" method="post"> <label for="store_id" style="font-size: 14px; margin-top: 10px; font-weight: bold; font-variant: small-caps;">Store ID:</label> <input type="text" name="first_name" value="" maxlength="30" style="width:49.6%; font-size: 30px;"<br /><?php if (isset($_POST['store_id'])) echo $_POST['store_id']; ?><br /></p> <form method="post" action="sox.php"> <input type="submit" style="width:90px; height: 35px; margin-left: 260px; -moz-border-radius: 10px;" name="submit" value="get info"> </form> </div> <div id="extraDiv1"><span></span></div> </html> </body>
Here's the second page (sox.php), which I would like to display the results:
<?php
if(isset($_POST['submit'])) {
$store_id=mysql_real_escape_string( $_POST['store_id'] );
$con = mysql_connect("localhost","root","....");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db(".....", $con);
$query = "SELECT * FROM retailers WHERE store_id='$store_id' ";
$result = mysql_query($query);
echo "<table class='sample'>";
while ($row = mysql_fetch_array($result)) {
//store id
echo "<th>Store ID</th>";
echo "<td>" . $row['store_id'] . "</td>";
echo "</tr>";
//name
echo "<th>Customer Name</th>";
echo "<td>" . $row['name'] ."</td>";
echo "</tr>";
//email
echo "<th>Email</th>";
echo "<td>".$row['email']."</td>";
echo "</tr>";
//repair number
echo "<th>Repair Number</th>";
echo "<td>".$row['repair_number']."</td>";
echo "</tr>";
//in date
echo "<th>In Date</th>";
echo "<td>".$row['in_date']."</td>";
echo "</tr>";
//est date
echo "<th>Estimated Date</th>";
echo "<td>".$row['est_date']."</td>";
echo "</tr>";
}
echo "</table>";
}
?>Theoretically, I would like to have the fields displayed horizontally rather than vertically, but that's something else of a battle.
Thanks!
![]() |
Similar Threads
- Custom page to login to Yahoo, Gmail, MSN etc (JavaScript / DHTML / AJAX)
- cPanel: email account creation. I need help making a PHP script. (PHP)
- PHP sessions/$_POST problem. Too Stressed today! (PHP)
- Parse Error in PHP (PHP)
- system login error (PHP)
- Php Syntax Error (PHP)
- question about connecting odbc to sql through php script (PHP)
- login script using sessions (PHP)
Other Threads in the PHP Forum
- Previous Thread: Credit card validation
- Next Thread: Pagepost Back Function
| Thread Tools | Search this Thread |
# 5.2.10 alexa apache api array beginner binary broken cakephp checkbox class clean clients cms code cron curl database date directory display dissertation dropdown dynamic echo echo$_get[x]changingitintovariable... email encode error fairness file files folder form forms function functions google href htaccess html image images include indentedsubcategory insert ip javascript joomla legislation limit link local login mail memberships menu mlm multiple multipletables mysql mysqlquery newsletters oop open paypal pdf persist php problem provider query radio random recursion remote rss script search server sessions sms sockets source space spam sql syntax system table tutorial update upload url validator variable video web youtube





