Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > PHP Development
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 09-15-2006, 05:27 PM   #11 (permalink)
O~Snapple
Moderator Of The Year
 
O~Snapple's Avatar
 
Join Date: Jul 2006
Location: Cali Breeze
Posts: 716
Send a message via MSN to O~Snapple Send a message via Skype™ to O~Snapple
Default Re: a PHP question

Well for every form you have an action for example...

[html]<FORM METHOD="POST" ACTION="register.php" onSubmit="return Form1_Validator(this)" name="Form1">

<P style="margin-top: 0; margin-bottom: 0"><font face="Tahoma">
<span style="font-size: 14px"><strong style="font-weight: 400">First Name:</strong></span><font size="2"><BR></font><font face="Tahoma" size="1">

<INPUT NAME="firstname" SIZE=25 MAXLENGTH=50></font></font></p>
<strong style="font-weight: 400"><span class="style4">Last Name</span><font size="2">:</font></strong><font size="2"><BR>
</font><font face="Tahoma" size="1">
<INPUT NAME="lastname" SIZE=25 MAXLENGTH=50><br>

</font><P style="margin-top: 0; margin-bottom: 0;"><font face="Tahoma">
<strong style="font-weight: 400"><font size="2">Company:</font></strong><font size="2"><BR>
</font><font face="Tahoma" size="1">
<INPUT NAME="company" SIZE=25 MAXLENGTH=50><br>
</font><span class="style4">Username:</span></font>
<br>
<INPUT NAME="username" SIZE=25 MAXLENGTH=50>
<br>
<font face="Tahoma"><strong style="font-weight: 400">Password:</strong><font size="2"><BR>
</font><font face="Tahoma" size="1">
<INPUT TYPE="password" NAME="password" SIZE=25 MAXLENGTH=25>
<br>

</font>Confirm Password:<font face="Tahoma" size="1"><br>
<INPUT TYPE="password" NAME="confirm" SIZE=25 MAXLENGTH=25>
</font></font>
<P style="margin-top: 0"><span style="font-size: 14px"><strong style="font-weight: 400">
<font face="Tahoma">E-Mail Address</font></strong><font face="Tahoma"><strong style="font-weight: 400">:</strong></font></span><font face="Tahoma"><font size="2"><BR>
</font><font face="Tahoma" size="1">
<INPUT TYPE="text" NAME="email" SIZE=25 MAXLENGTH=100></font></font><br>
Requested Access Level:<br>
<label>
<select name="access">
<option>Access Level Request</option>
<option>Employee</option>
<option>Patient</option>
<option>Referral</option>
</select>
</label>
</p>
<P style="margin-top: 0; margin-bottom: 0">
<INPUT TYPE="submit" NAME="submit" VALUE="Submit" style="font-family: Tahoma"></p>
</FORM>[/html]

You notice on the top my Action is register.php which looks like this

PHP Code:
<?php

//prevents caching
header("Expires: Sat, 01 Jan 2000 00:00:00 GMT");
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
header("Cache-Control: post-check=0, pre-check=0",false);
session_cache_limiter();

session_start();

//require the config file
require ("config.php");
require (
"functions.php");

//checks password length
if (password_check($min_pass$max_pass$_POST[password]) == "no")
{
?>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="refresh" content="0; url=javascript:history.go(-1)">
<title>Registration</title>
<script language="JavaScript">
<!--
function FP_popUpMsg(msg) {//v1.0
 alert(msg);
}
// -->
</script>
</head>

<body onLoad="FP_popUpMsg('Your password must be between <? echo $min_pass?> & <? echo $max_pass?> characters.')">

</body>

</html>
<?
exit;
}

//make the connection to the database
$connection = @mysql_connect($server$dbusername$dbpassword) or die(mysql_error());
$db = @mysql_select_db($db_name,$connection)or die(mysql_error());

//make query to database
$sql ="SELECT * FROM $table_name WHERE username= '$_POST[username]'";
$result = @mysql_query($sql,$connection) or die(mysql_error());

//get the number of rows in the result set
$num mysql_num_rows($result);

//checks it see if that username already exists
if ($num != 0){

echo 
"<P>Sorry, that username already exists.</P>";
echo 
"<P><a href=\"#\" onClick=\"history.go(-1)\">Try Another Username.</a></p>";
exit;

}
else
{
$sql "INSERT INTO $table_name VALUES ('$_POST[firstname]', '$_POST[lastname]', '$_POST[company]', '$_POST[username]', password('$_POST[password]'), 'Users', '', '', '$pchange', '$_POST[email]', '$_POST[access]', '$default_url', '$verify', '')";

$result = @mysql_query($sql,$connection) or die(mysql_error());
}

//checks to see if the user needs to verify their email address before accessing the site
if ($verify == "0")
{
    
$mailheaders "From: www$domain\n";
    
$mailheaders .= "Your account has been created.\n";
    
$mailheaders .= "Please activate your account now by visiting this page:\n";
    
$mailheaders .= "$base_dir/activate.html\n";


    
$to "$_POST[email]";
    
$subject "Please activate your account";

mail($to$subject$mailheaders"From: No Reply <$adminemail>\n");

}else{
    
header('Location:login.html');
}



?>

<HTML>
<HEAD>
<TITLE>Add a User</TITLE>
</HEAD>
<BODY>
<H1>Please check your email to activate your account.</H1>
</BODY>
</HTML>

So when the form is filled out and the user clicks teh button at the bottom, register.php loads and preforms the operations which checks password length and opens up a connection with the Database and whatever you decide to have it do.

This is where you would want to have the checks to see if the form has been filled out correctly. IE password length, not a e-mail that has already been used etc...

Make Sense???

~Snapple
__________________
The Real Truth
Epademik Emcee Esq. New Album The 3rd Finger is in Stores Now!
Snap Marketing Management and Consulting
O~Snapple is offline   Reply With Quote
Sponsored Links
Old 09-15-2006, 05:49 PM   #12 (permalink)
BrotherBear
Member
 
Join Date: Jun 2006
Posts: 108
Default Re: a PHP question

yes it makes sense but where in phpMyAdmin should I put "form1.php"

I already have a table the name is Customers the ID is form_ID and the other fields are fname lname email and age and comments or just by putting form1.php in the HTML it's enough?

BB
__________________
http://bbanddisney.freeprohost.com/

We Changed the Address, Fresh News From Disney and my Career
BrotherBear is offline   Reply With Quote
Old 09-15-2006, 10:42 PM   #13 (permalink)
alwaysinit
Junior Member
 
alwaysinit's Avatar
 
Join Date: Aug 2006
Posts: 36
Default Re: a PHP question

heehee, snapple,s quick, he answered while I was typing an answer. now I most post this retarded message

Last edited by alwaysinit : 09-15-2006 at 10:44 PM.
alwaysinit is offline   Reply With Quote
Old 09-15-2006, 10:50 PM   #14 (permalink)
alwaysinit
Junior Member
 
alwaysinit's Avatar
 
Join Date: Aug 2006
Posts: 36
Default Re: a PHP question

***POST EDITED BY O~SNAPPLE PLEASE USE CORRECT TAGS WHEN POSTING CODE***
Do it like this in your form.html:[html]
<form action="form1.php" method="post">[/html]
then just put the php page and html page in the same folder on your server
That line of code calls the php page into performing it's functions(when user clicks submit)

And "form1.php" goes in your folder that has your form.html page( Does'nt go inside phpmyadmin)
Just make sure the two pages are together and it will work the way O-snap said

Last edited by alwaysinit : 09-15-2006 at 10:56 PM.
alwaysinit is offline   Reply With Quote
Old 09-15-2006, 11:00 PM   #15 (permalink)
alwaysinit
Junior Member
 
alwaysinit's Avatar
 
Join Date: Aug 2006
Posts: 36
Default Re: a PHP question

Hey Snap, Can I recommend brother bear to a tutorial that's on another site, it really helped me understand fast.
alwaysinit is offline   Reply With Quote
Old 09-16-2006, 02:49 AM   #16 (permalink)
O~Snapple
Moderator Of The Year
 
O~Snapple's Avatar
 
Join Date: Jul 2006
Location: Cali Breeze
Posts: 716
Send a message via MSN to O~Snapple Send a message via Skype™ to O~Snapple
Default Re: a PHP question

For sure, make sure that you post the link rather than copy whats on their page its a fine line regarding copyright issues so always link to their page if necessary.

and Brothr Bear:
The Action is what happens when someone clicks the submit button. in the Action script you would want to call the MySQL database and make changes to the data base or querys, theres really endless possibilities. Im a huge fan of PHP. i learn more about it every day and i started learning it by just examining code.

~Snapple
__________________
The Real Truth
Epademik Emcee Esq. New Album The 3rd Finger is in Stores Now!
Snap Marketing Management and Consulting
O~Snapple is offline   Reply With Quote
Old 09-16-2006, 03:15 AM   #17 (permalink)
alwaysinit
Junior Member
 
alwaysinit's Avatar
 
Join Date: Aug 2006
Posts: 36
Default Re: a PHP question

Check out this link Brother BearPHP Help: Creating a Membership System with PHP and MySQL
It is a tutorial for creating a membership system. If you take the time to go through it you will find actual working code for all those things you want to do. Plus you will then have a much better understanding of how PHP scripts(pages) interact with your forms and html pages.
Oh and it's easier to follow the tutorial if you set everything up the way he has it set up. Create a new database in phpMyAdmin and set up the table with fields just like he does.
alwaysinit is offline   Reply With Quote
Old 09-18-2006, 03:48 PM   #18 (permalink)
BrotherBear
Member
 
Join Date: Jun 2006
Posts: 108
Default Re: a PHP question

thank you alwaysinit and snap I'll read carefully the tutorials and if I have any other questions well I'll come here, thanks

BB
__________________
http://bbanddisney.freeprohost.com/

We Changed the Address, Fresh News From Disney and my Career
BrotherBear is offline   Reply With Quote
Old 09-19-2006, 07:03 PM   #19 (permalink)
BrotherBear
Member
 
Join Date: Jun 2006
Posts: 108
Default Re: a PHP question

so to resume in the page of the form you have to put the text areas and form object and when you press the submit button in the next page you hav to put the mysql stuff so the info can be stored right?

BB
__________________
http://bbanddisney.freeprohost.com/

We Changed the Address, Fresh News From Disney and my Career
BrotherBear is offline   Reply With Quote
Old 09-19-2006, 07:07 PM   #20 (permalink)
alwaysinit
Junior Member
 
alwaysinit's Avatar
 
Join Date: Aug 2006
Posts: 36
Default Re: a PHP question

Sounds exactly right to me
alwaysinit is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:54 PM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums