about using Mysql User and Pass to login to page
sup? all i just find a code to edit table in mysql but i don't know how to set it have to login every i go to login page if anyone can help me out that will great :D
birthdays_login.php
PHP Code:
<html><head><title>Birthdays Login</title>
<style type="text/css">
form{ font-family: Arial ,sans-serif;font-style : normal ;font-size : 9pt; font-weight :normal}
</style>
</head>
<body>
<div align="center">
<table width="350" cellpadding="10" cellspacing="0" border="2">
<tr align="center" valign="top">
<td align="left" colspan="1" rowspan="1" bgcolor="#64B1FF">
<form method="POST" action="birthdays_dbase_interface.php">
<?
print "Enter Username: <input type=text name=username size=20><br>\n";
print "Enter Password: <input type=password name=password size=20><br>\n";
print "<br>\n";
print "<input type=submit value=Submit><input type=reset>\n";
?>
</form>
</td></tr></table>
</div>
</body>
</html>
birthdays_change_form.php
PHP Code:
<html><head><title></title></head>
<body>
<?
$id=$_POST['id'];
$db="mydatabase";
$link = mysql_connect(localhost,$_POST['username'],$_POST['pass']);
//$link = mysql_connect("localhost");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$query=" SELECT * FROM birthdays WHERE id='$id'";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {
$name=mysql_result($result,$i,"name");
$birthday=mysql_result($result,$i,"birthday");
?>
<table width="300" cellpadding="10" cellspacing="0" border="2">
<tr align="center" valign="top">
<td align="center" colspan="1" rowspan="1" bgcolor="#64b1ff">
<h3>Edit and Submit</h3>
<form action="birthdays_change_record.php" method="post">
<input type="hidden" name="username" value="<?php print $_POST['username']?>">
<input type="hidden" name="pass" value="<?php print $_POST['pass']?>">
<input type="hidden" name="ud_id" value="<? echo "$id" ?>">
Name: <input type="text" name="ud_name" value="<? print "$name"?>"><br>
Birthday: <input type="text" name="ud_birthday" value="<? echo "$birthday"?>"><br>
<input type="Submit" value="Update">
</form>
</td></tr></table>
<?
++$i;
}
?>
</body>
</html>
birthdays_change_record.php
PHP Code:
<html><head><title></title></head>
<body>
<?
$user=$_POST['username'];
$password=$_POST['password'];
$ud_id=$_POST['ud_id'];
$ud_name=$_POST['ud_name'];
$ud_birthday=$_POST['ud_birthday'];
$db="mydatabase";
$link = mysql_connect("localhost",$_POST['username'],$_POST['password']);
//$link = mysql_connect("localhost");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
mysql_query(" UPDATE birthdays SET name='$ud_name' ,birthday='$ud_birthday' WHERE id='$ud_id'");
echo "Record Updated";
mysql_close($link);
?>
<form method="POST" action="birthdays_update_form.php">
<input type="hidden" name="username" value="<?php print $_POST['username']?>">
<input type="hidden" name="pass" value="<?php print $_POST['password']?>">
<input type="submit" value="Change Another">
</form><br>
<form method="POST" action="birthdays_dbase_interface.php">
<input type="hidden" name="username" value="<?php print $_POST['username']?>">
<input type="hidden" name="pass" value="<?php print $_POST['password']?>">
<input type="submit" value="Dbase Interface">
</form>
</body>
</html>
Re: about using Mysql User and Pass to login to page
birthdays_create_database.php
PHP Code:
<html><head><title>Birthdays Create Database</title></head>
<body>
<?
$link = mysql_connect("localhost", "root", "testsql");
if (! $link)
die("Couldn't connect to MySQL");
//create database
mysql_create_db("mydatabase")or die("Create Error: ".mysql_error());
mysql_close($link);
?>
</body>
</html>
birthdays_create_table.php
PHP Code:
<html><head><title>Birthdays Create Table</title></head>
<body>
<?
$db="mydatabase";
$link = mysql_connect("localhost", "root", "testsql");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Select DB Error: ".mysql_error());
//create table
mysql_query("CREATE TABLE birthdays( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), name VARCHAR(30), birthday VARCHAR(7))")or die("Create table Error: ".mysql_error());
mysql_close($link);
?>
</body>
</html>
birthdays_dbase_interface.php
PHP Code:
<html><head><title></title></head>
<body>
<table width="300" cellpadding="10" cellspacing="0" border="2">
<tr align="center" valign="top">
<td align="left" colspan="1" rowspan="1" bgcolor="64b1ff">
<h3>Birthdays Interface</h3>
<form method="POST" action="birthdays_insert_form.php">
<input type="hidden" name="username" value="<? print $_POST['username']?>">
<input type="hidden" name="password" value="<? print $_POST['password']?>">
<input type="submit" value="Insert Record">
</form><br>
<form method="POST" action="birthdays_display_records.php">
<input type="hidden" name="username" value="<? print $_POST['username']?>">
<input type="hidden" name="password" value="<? print $_POST['password']?>">
<input type="submit" value="Display Records">
</form><br>
<form method="POST" action="birthdays_update_form.php">
<input type="hidden" name="username" value="<? print $_POST['username']?>">
<input type="hidden" name="password" value="<? print $_POST['password']?>">
<input type="submit" value="Update Records">
</form><br>
<form method="POST" action="birthdays_delete_form.php">
<input type="hidden" name="username" value="<? print $_POST['username']?>">
<input type="hidden" name="password" value="<? print $_POST['password']?>">
<input type="submit" value="Delete Record">
</form><br>
</td></tr></table>
</body>
</html>
birthdays_delete_form.php
PHP Code:
<html><head><title>Birthdays Delete Form</title></head>
<body>
<?
$db="mydatabase";
//$link = mysql_connect("localhost");
$link = mysql_connect("localhost",$_POST['username'],$_POST['password']);
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM birthdays" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>
<br>
<form method="POST" action="birthdays_delete_record.php">
<pre>
Enter Line Number to Delete: <input type="text" name="id" size="5">
<input type="submit" value="Submit"><input type="reset">
</pre>
</form>
</body>
</html>
Re: about using Mysql User and Pass to login to page
birthdays_delete_record.php
PHP Code:
<html><head><title>Birthdays Delete Record</title></head>
<body>
<?
$user=$_POST['username'];
$password=$_POST['password'];
$id=$_POST['id'];
$db="mydatabase";
//$link = mysql_connect("localhost");
$link = mysql_connect("localhost",$_POST['username'],$_POST['password']);
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
mysql_query("DELETE FROM birthdays where id=$id")or die("Delete Error: ".mysql_error());
mysql_close($link);
print "Record Removed.\n";
?>
<br><br>
<form method="POST" action="birthdays_delete_form.php">
<input type="hidden" name="username" value="<?php print $_POST['username']?>">
<input type="hidden" name="pass" value="<?php print $_POST['password']?>">
<input type="submit" value="Delete Another">
</form><br>
<form method="POST" action="birthdays_dbase_interface.php">
<input type="hidden" name="username" value="<?php print $_POST['username']?>">
<input type="hidden" name="pass" value="<?php print $_POST['password']?>">
<input type="submit" value="DBase Interface">
</form>
</body>
</html>
birthdays_display_records.php
PHP Code:
<html>
<head><title>(Title Here)</title></head>
<body>
<?php
$db="mydatabase";
//$link = mysql_connect("localhost");
$link = mysql_connect("localhost",$_POST['username'],$_POST['password']);
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM birthdays" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>
</body>
</html>
birthdays_insert_form.php
PHP Code:
<html><head><title>Birthdays Insert Form</title></head>
<body>
<table width="300" cellpadding="5" cellspacing="0" border="2">
<tr align="center" valign="top">
<td align="left" colspan="1" rowspan="1" bgcolor="64b1ff">
<h3>Insert Record</h3>
<form method="POST" action="birthdays_insert_record.php">
<!--The hidden fields are provided to maintain state.
They are used to pass the username and password from script to script.-->
<!--
<input type="hidden" name="username" value="<? print $_POST['username'] ?>">
<input type="hidden" name="password" value="<? print $_POST['password'] ?>">
//-->
<?
print "Enter name: <input type=text name=name size=20><br>\n";
print "Enter Birthday: <input type=text name=birthday size=10><br>\n";
print "<br>\n";
print "<input type=submit value=Submit><input type=reset>\n";
?>
</form>
</td></tr></table>
</body>
</html>
birthdays_insert_record.php
PHP Code:
<html><head><title>Birthdays Insert Record</title></head>
<body>
<?
$name=$_POST['name'];
$birthday=$_POST['birthday'];
$db="mydatabase";
//$link = mysql_connect("localhost");
$link = mysql_connect("localhost",$_POST['username'],$_POST['password']);
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO birthdays (name, birthday) VALUES ('$name','$birthday')")or die("Insert Error: ".mysql_error());
mysql_close($link);
print "Record added\n";
?>
<form method="POST" action="birthdays_insert_form.php">
<input type="submit" value="Insert Another Record">
</form>
</body>
</html>
birthdays_update_form.php
PHP Code:
<html><head><title>Birthdays Update Form</title></head>
<body>
<?
$db="mydatabase";
//$link = mysql_connect("localhost");
$link = mysql_connect("localhost",$_POST['username'],$_POST['password']);
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$result = mysql_query( "SELECT * FROM birthdays" )
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($result);
print "There are $num_rows records.<P>";
print "<table width=200 border=1>\n";
while ($get_info = mysql_fetch_row($result)){
print "<tr>\n";
foreach ($get_info as $field)
print "\t<td><font face=arial size=1/>$field</font></td>\n";
print "</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>
<br>
<form method="POST" action="birthdays_change_form.php">
<pre>
Enter Line Number to Edit: <input type="text" name="id" size="5">
<input type="submit" value="Submit"><input type="reset">
</pre>
</form>
</body>
</html>
tHANKX you for the help :Dh
1 Attachment(s)
Re: about using Mysql User and Pass to login to page
here is the zip file i downloaded from the net
h