View Full Version : Login Script
munkynpunky
08-07-2007, 02:37 PM
Hey guys,
I need some help, Im trying to make a members section, and so i have a username and password page, which passes to a login.php script..
username and password are passed to this page
<?php
include "connection.php";
// Connect to server and select databse.
if (!$con)
{
die('Could not connect: ' . mysql_error() );
}
mysql_select_db($db, $con);
// username and password sent from signup form
$username=$_POST['username'];
$username=$_POST['password'];
$sql="SELECT * FROM our_info WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "failed.html"
session_register("username");
session_register("password");
header("location:../main.php");
}
else {
header("location:../failed.html");
}
?>
but for some reason it keeps sending me to failed.php, even though the username and password are correct...
any thoughts?
munkynpunky
08-07-2007, 02:39 PM
oh....
how stupid am i??
// username and password sent from signup form
$username=$_POST['username'];
$username=$_POST['password'];
ok, so, thats now working
munkynpunky
08-07-2007, 02:46 PM
ok,
this is the script
<?php
include "connection.php";
// Connect to server and select databse.
if (!$con)
{
die('Could not connect: ' . mysql_error() );
}
mysql_select_db($db, $con);
// username and password sent from signup form
$user=$_POST['username'];
$pass=$_POST['password'];
$sql="SELECT * FROM our_info WHERE username='$username' and password='$password'";
$result=mysql_query($sql);
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1){
// Register $myusername, $mypassword and redirect to file "failed.html"
session_register("user");
session_register("pass");
header("location:../main.php");
}
else {
header("location:../failed.html");
}
?>
that worked, however, on another script, it stopped working..
<?PHP
//Get the data to update
$contact = $_POST['contact'];
$business = $_POST['business'];
$add1 = $_POST['add1'];
$add2 = $_POST['add2'];
$town = $_POST['town'];
$county = $_POST['county'];
$postcode = $_POST['postcode'];
$country = $_POST['country'];
$tel = $_POST['tel'];
$fax = $_POST['fax'];
$email = $_POST['email'];
$web = $_POST['web'];
$view = $_POST['view'];
// Make Connection
include 'connection.php';
if (!$con)
{
die('Could not connect: ' . mysql_error() );
}
mysql_select_db($db, $con);
//Run the update query
$sql = "UPDATE our_info SET contact = '$contact' , business = '$business' , add1 = '$add1' , add2 = '$add2' , town = '$town' , county = '$county' , postcode = '$postcode' , country = '$country' , tel = '$tel' , fax = '$fax' , email = '$email' , web = '$web' , view = '$view' WHERE username = '$user'";
mysql_query( $sql , $con ) or die( "<strong>Query Error</strong>: " . mysql_error() . "<br><strong>Query</strong>: $sql<br><br>" );
echo $user ;
//Close the connection
mysql_close($con);
?>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=../yourdetails.php">
the echo works fine but it doesnt update the database..?
any thoughts?
tech_support
08-08-2007, 06:34 AM
What error does it give?
allahverdi
08-08-2007, 06:44 AM
I think i can make a login script but i dont know what you need and etc.
i have the script for log in
<html>
<head>
<script>
function show(){
document.resetpass.style.display="block";
}
</script>
<title>4 charx</title>
</head>
<body>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<form method="POST" action="log_con.php">
<div align="center">
<table border="0" width="854" id="table1">
<tr>
<td width="100%" colspan="2" align=center><b> Admin Panel Entry</b></td>
</tr>
<tr>
<td width="44%" align=right>Username:</td>
<td width="55%">
<input name="username" size="20" style="font-family: Tahoma; font-size: 8pt; color: #FFFFFF; background-color:#838FB9"></td>
</tr>
<tr>
<td width="44%" align=right>Password:</td>
<td width="55%">
<input type="password" name="password" size="20" style="font-family: Tahoma; font-size: 8pt; color: #FFFFFF; background-color:#838FB9"></td>
</tr>
<tr>
<td width="44%"> </td>
<td width="55%">
<input type="submit" value="Enter"></td>
</tr>
</table>
</div>
</form>
<center>
<a href="javascript:show()"><font color="#FF0000">Şifrəmi unutdum</font></a>
<form action="sendpass.php" method="post" name="resetpass" style='display:none'><br>
Qeydiyyatdan keçən e-mail-i daxil edin:<input type=text name="email" value="" size=20>
<input type=submit value="Send password">
</form>
</body>
</html>
this is a log in page
and this is the log_conf script
<?
session_start();
$username=$_POST["username"];
$password=md5($_POST["password"]);
include_once("../include/connect.inc"); connect(1,2);
$info=mysql_query("select * from login where username='$username' and password='$password'");
$count=mysql_num_rows($info);
if ($count>0){
$log=mysql_fetch_array($info);
session_register("username","password");
$login=$log["username"];
$password=$log["password"];
Header("Location: admin.php");
}
else{
Header("Location: login.php");
}
?>
i dont think that will work you need to change all thing but i can send you all files to your e-mail if you want
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.