Looking for a mentor on php/mysql
fbsd_user
fbsd_user at a1poweruser.com
Wed Feb 22 13:32:55 PST 2006
I am trying to teach my self php/mysql/html programming.
I have done native static html web sites before.
Running FreeBSD 6.0 with apache13, php, and mysql all installed and
working.
Have read a few php books and searched the web for code snippets.
Have been on some of the php forum sites, but responses are not forth
coming.
Looking for a mentor to guide me with puting all the pieces together.
I have a working panel for registering a user that writes to a flat
text file.
Need guidance in changing this to use mysql. Would email you direct
outside of the questions list.
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title>learning PHP </title>
</head>
<body>
<h1 ALIGN="center"> </h1>
<h1 ALIGN="center"><font size="6"> Membership
Registration</font></h1>
<font FACE="Courier New" SIZE="2"><p> </p>
<p>Enter your info below.</font></p>
<p> </p>
<form method="POST" action="<?php echo($PHP_SELF); php?>">
<input type="hidden" name="action" value="add"><br>
<p>Account ID
<input type="text" name="id" size="20"></p>
<p>Account Password
<input type="text" name="pw" size="20"></p>
<p>First
Name
<input type="text" name="first-name" size="20"></p>
<p>Last
Name
<input type="text" name="last-name" size="20"></p>
<p>Address
Line
<input type="text" name="address" size="20"></p>
<p>City &nb
sp; &
nbsp;
<input type="text" name="city" size="20"></p>
<p>State &n
bsp;
<input type="text" name="state" size="20"></p>
<p>Zip &nbs
p;
<input type="text" name="zip" size="20"></p>
<p> </p>
<p> &
nbsp;
<input type="submit" value="Submit" name="B1"><input type="reset"
value="Reset" name="B2"></p>
</form>
<p> </p>
<?php
$file_directory = $_SERVER["DOCUMENT_ROOT"];
$user_ip = $_SERVER["REMOTE_ADDR"];
$error = 'Could not open the file! Verify permissions & path are
correct.';
if($_POST['action'] == "add")
{
if($filehandle = fopen("$file_directory/members.php", "a"))
{
flock($filehandle, 2); // lock file
fputs($filehandle,
$_POST['id'].":".$_POST['pw'].":".$_SERVER['REMOTE_ADDR'].":".$_POST['
first-name'].":".$_POST['last-name'].":".$_POST['address'].":".$_POST[
'city'].":".$_POST['state'].":".$_POST['zip']."\n");
flock($filehandle, 3); // unlock file
fclose($filehandle);
print("Successfully added ".$_POST['id']." to the file");
}
else
{
echo($error);
}
}
php?>
</body></html>
More information about the freebsd-questions
mailing list