•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,451 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,587 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1930 | Replies: 22
![]() |
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
since all the databases are done, please post the table names and the fields in each to so i can make the code. i typed up the login page but to use the mysql sever you need to have this page made for me.
SAVE AS mysql.php
Here is the html form
Here is login.php
It goes to a member.php page where the login name and first and last names are shown. other features will be added once you explain in more detail exactly what you want.
SAVE AS mysql.php
<?php
$con = mysql_connect("host","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$database = mysql_select_db('db_name', $con);
if (!$database) {
echo "DATABASE COULDN'T BE SELECTED";
}
?>Here is the html form
<form action="login.php" method="post"> <p>Username:<input type="text" name="user" /></p> <p>Password:<input type="password" name="pass" /></p> <p><input type="submit" name="submit" value="login" /><input type="reset" /></p> </form>
Here is login.php
<?php
session_start();
if (!isset($_SESSION['user']) || !isset($_SESSION['pass'])) {
function check($fieldname)
{
if(!preg_match("/[^a-zA-Z0-9\.\-\Ä\ä\Ö\ö\Ü\ü\,\ ]+$/s",$fieldname)) {
return TRUE;
}
else {
return FALSE;
}
}
$user = $_REQUEST['user'];
$pass = $_REQUEST['pass'];
if (isset($_POST['submit'])) {
$error_msg = '';
$error = 0;
if ($user == NULL) {
$error_msg .= "Username field is not filled out\\n\\n";
$error++;
}
if (!$user == NULL && !check($user)) {
$error_msg .= "Username field contains illegal characters\\n\\n";
$error++;
}
if ($pass == NULL) {
$error_msg .= "Password field is not filled out\\n\\n";
$error++;
}
if (!$pass == NULL && !check($pass)) {
$error_msg .= "Password field contains illegal characters\\n\\n";
$error++;
}
if ($error > 0) {
$error_msg .= "There currently are " . $error . " errors";
echo '<script type="text/javascript">alert ("' . $error_msg . '");</script>';
}
if ($error == 0) {
include 'mysql.php';
$sql = "SELECT * FROM users WHERE users.username = '" . $user . "'";
$check = mysql_query($sql);
if (mysql_num_rows($check) == 0) {
die('Username doesn\'t exist');
}
while ($q = mysql_fetch_assoc($check)) {
if ($q['password'] !== $pass) {
die('Username or Password is incorrect');
}
$_SESSION['user'] = $user;
$_SESSION['pass'] = $pass;
$_SESSION['fname'] = $q['firstname'];
$_SESSION['lname'] = $q['lastname'];
echo '<meta http-equiv="refresh" content="0;url=member.php" />';
}
mysql_close($con);
}
}
else {
echo 'Please fill out the form first before visting this page';
}
}
else {
echo 'You are already logged in';
}
?>It goes to a member.php page where the login name and first and last names are shown. other features will be added once you explain in more detail exactly what you want.
•
•
Join Date: Sep 2007
Posts: 30
Reputation:
Rep Power: 2
Solved Threads: 0
by the way i put the username password and the field names in the same field.. is it ok to that?
the table name is student
and the field names that needed to be shown is the last name, first name, middle initial, gender, birthdate,
yearlevel, course and email add thats the infos need to be shown after login...
in next page which is the encoding page ... this is where will i add subjects.. as i say is it possible that all of the available subjects will be display in a table and from there i'll just click what subject i want to enroll and it will be display in the table below?.. thx very much for hel keith! hihi...
the table name is student
and the field names that needed to be shown is the last name, first name, middle initial, gender, birthdate,
yearlevel, course and email add thats the infos need to be shown after login...
in next page which is the encoding page ... this is where will i add subjects.. as i say is it possible that all of the available subjects will be display in a table and from there i'll just click what subject i want to enroll and it will be display in the table below?.. thx very much for hel keith! hihi...
Last edited by ronghel : Sep 29th, 2007 at 11:04 pm.
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
sorry about this, i know this might be a burden on you but i have a php code to create the student table. you have to delete yours first or the code will fail. i am doing this so there is no confusion of field names and such when i create the code.
here is the code:
just save it as something and run it on your server after filling out the database connect info.
here is the code:
<?php
$con = mysql_connect("host","username","password");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$database = mysql_select_db('db_name', $con);
if (!$database) {
echo "DATABASE COULDN'T BE SELECTED";
}
$sql = 'CREATE TABLE student(
id INT AUTO_INCREMENT PRIMARY KEY NOT NULL,
username VARCHAR(40) NOT NULL,
password VARCHAR(40) NOT NULL,
lname VARCHAR(40) NOT NULL,
fname VARCHAR(40) NOT NULL,
minitial VARCHAR(5) NOT NULL,
gender VARCHAR(30) NOT NULL,
birthdate VARCHAR(30) NOT NULL,
yearlevel VARCHAR(20) NOT NULL,
course VARCHAR(60) NOT NULL,
email VARCHAR(60) NOT NULL)';
$query = mysql_query($sql);
if (!$query) {
echo 'query unsuccessful';
}
else {
echo 'query ok';
}
mysql_close($con);
?>just save it as something and run it on your server after filling out the database connect info.
•
•
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation:
Rep Power: 3
Solved Threads: 72
•
•
Join Date: Feb 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
hey everyone, im a newbie here. can someone help me programming php with mysql? i need to figure out my pre-enlistment system online using these languages but im having trouble encoding. even a program of enrollment system could help. just want to have an idea how it works. plsssss.! i need it asap. thanks in advance....
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,628
Reputation:
Rep Power: 12
Solved Threads: 311
Welcome to daniweb inthan12
If you have problem with your code you better post it and point as to your problematic areas. Unfortunately nobody will do it for you asap. Some more info can be found on
homework announcement.
If you have problem with your code you better post it and point as to your problematic areas. Unfortunately nobody will do it for you asap. Some more info can be found on
homework announcement.
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), Coding the Architecture
Publilius Syrus
(~100 BC)
LJC - London Java Community, JAVAWUG (Java Web User Group), Coding the Architecture
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- some thoughts of enrollment system in php??? (PHP)
- How to compaire Stored Dates with System Date (PHP-MYSQL) (PHP)
- Move folder in Mila function using PHP (PHP)
- 4years experienced php developer@$9.95/hour (Post your Resume)
- Zend PHP Certification (PHP)
- PHP Programmer interested in an existing project? Game! =o] (PHP)
- Close call ... (DaniWeb Community Feedback)
Other Threads in the PHP Forum
- Previous Thread: php form - pop-up window possible?
- Next Thread: Updating file with web form



Linear Mode