February 18th, 2003, 12:38 AM
|
#1 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
|
Does anyone know where I can find a tutorial on how to make a PHP Form Processor so it e-mails me the form and so it creates a thing in MySQL??? This is for a user registration thing.
Thanks! |
| |
February 18th, 2003, 02:09 AM
|
#2 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Arizona
Posts: 2,538
|
Creates a thing in MySQL huh? Shouldn't be too hard. I'm gonna post two scripts of mine that you can hack away at and make 'em work to do what you need.
The script below must be passed information from an HTML form. Create a Send button or something that submits that POSTs the information to this document. PHP Code: <?php
echo "<font size=\"-1\">Thank you for filling out our form $name. This submission will be e-mailed to SITE NAME immediately.<br>
Return to <a href=\"index.php\">Index</a>.<br>";
$recipient = "you@your_domain.com";
$subject = "New Registration Request";
$message = "Hello!\n\nHi, $name has requested membership and has included the following information.
Name: $name
E-Mail: $e-mail
Subject: $subject
Message: $message .\n\n";
$extra = "From: $user_email
\nReply-To: you@your_domain.com
\n";
mail ($recipient, $subject, $message, $extra);
?> You need to pass the script most of those variables from the form page. $name, $e-mail, and any other variables must be POSTed from the form. The other varibables are specified in the script.
Here's one that'll post information to a MySQL DB. PHP Code: <?
mysql_connect("domain_name.com","YourName","Password"); //then connect as user
mysql_select_db("MyDatabase"); //select which database you want to edit
$result=MYSQL_QUERY("INSERT INTO table (field1,field2,field3)".
"VALUES ('$name', '$e-mail', '$whatever')"); //Insert the values into the correct database
print "<p>Content has been insterted into the database.<br>
?> If my script doesn't work, sorry. I just hacked away at it to take out my personal information.  I'll try to help you with whatever problems you have though.
Last edited by Praetorian : February 18th, 2003 at 07:11 PM.
|
| |
February 18th, 2003, 02:14 AM
|
#3 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
|
Ok, thanks. I will look at it tomorrow when I have a chance. |
| |
February 18th, 2003, 06:14 PM
|
#4 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
|
Thanks, again. I did the the form processor to work but, I have a problem. I must not have the form thing made out correctly because whenever it sends me an e-mail it sends none of the information made out on the form neither does it show anything in the database. So I have something wrong. You have to forgive me. This is probably something so simple. It is just that I am new to web programming and am trying to learn php.
To view the page click here.
Last edited by embj : February 18th, 2003 at 06:17 PM.
|
| |
February 18th, 2003, 06:43 PM
|
#5 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
|
Ooops, I hit the quote instead of edit. I was just gonna add this to my previous post but, I can't delete this so I will leave it here.
Also, how do you center text in php? You know, like when you use echo and print. |
| |
February 18th, 2003, 07:10 PM
|
#6 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Arizona
Posts: 2,538
|
Just type this: PHP Code: echo "<div align=\"center\">CENTERED TEXT</div>";
|
| |
February 18th, 2003, 07:21 PM
|
#7 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
|
Thanks, again. Do you know the answer to my other question? |
| |
February 18th, 2003, 07:40 PM
|
#8 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Arizona
Posts: 2,538
|
Registration Form Quote:
<FORM method="POST" action="formprocessor.php">
<center>
<TR>
<TD width="598" height="745">
<TABLE border=0 width="587">
<TR>
<TD colspan="2">
<B>Name:</B></FONT>
</TD>
<TD width="316">
<input type="text" size="25" name="name">
</TD>
</TR>
<TR>
<TD colspan="2">
<B>User Name:</B></FONT>
</TD>
<TD width="316">
<input type="text" size="25" name="user_name">
</TD>
</TR>
<TR>
<TD colspan="2">
<B>E-Mail Address:</B></FONT>
</TD>
<TD width="316">
<input type="text" size="25" name="user_email">
</TD>
</TR>
<TR>
<TR>
<TD colspan="2"><B>Password:</FONT></B></TD>
<TD width="316">
<input type="text" size="25" name="password">
</TD>
</TR>
<TR>
<TD colspan="2"><B>Confirm Password:</FONT></B> </TD>
<TD width="316">
<input type="text" size="25" name="confirm_password">
</TD>
</TR>
<TR>
<TD colspan="2">
<TABLE border=0 width="100%" align="center">
<TR>
<TD width="77%">
<input type="submit" name="submit" value="submit">
</TD>
<TD valign=TOP width="23%">
<INPUT type="reset" value="Reset" name="reset">
</TD>
</TR>
</TABLE>
</TD>
<TD width="316">
</TD>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
</FORM>
| FormProcessor.php PHP Code: <?php
echo*"<font*size=\"-1\">Thank*you*for*filling*out*our*form*$name.*This*submission*will*be*e-mailed*to*SITE*NAME*immediately.<br>
Return*to*<a*href=\"index.php\">Index</a>.<br>";
$recipient*=*"you@your_domain.com"; //Your E-Mail Address
$subject*=*"New Registration Request"; //E-Mail Subject Line
$message*=*"Hello!\n\nHi,*$name*has*requested*membership*and*has*included*the*following*information. //Message included in e-mail
Name:*$name //Registrants Name
Username: $user_name //User's Handle
E-Mail:*$user_email //Registrants E-Mail
Password: $password //User's Password
Confirm Password: $confirm_password //Confirmed Password
\nReply-To:*you@your_domain.com\n"; //Reply-To address
mail*($recipient,*$subject,*$message,*$extra); //Mails information to $recipient
mysql_connect("domain_name.com","YourName","Password");*//then connect as user
mysql_select_db("MyDatabase");*//select which database you want to edit
$result=MYSQL_QUERY("INSERT INTO table (name,username,email,password, confirm_password)"."VALUES*('$name', '$user_name', '$user_email', '$password', '$confirm_password')");*//Insert the values into the correct database
?> That should work. Give it a shot. Just edit the MySQL thing again to contain your information and your extact fields in the table. LMK exactly what problems you're having after this. |
| |
February 18th, 2003, 08:10 PM
|
#9 (permalink)
| | Ultimate Member
Join Date: Dec 2002 Location: Fayetteville, NC
Posts: 1,385
|
Still, nothing. I get this in my e-mail.
Hello! Webmaster
Hi, has requested membership and has included the following information.
Name:
E-Mail: -mail
Subject: New Registration Request
Message: . |
| |
February 19th, 2003, 07:55 PM
|
#10 (permalink)
| | Ultimate Member
Join Date: Oct 2001 Location: Arizona
Posts: 2,538
|
Hmm....that script should work. I don't see why $user_email is not getting passed through, and at least some of the message should appear. Remove $extra from the mail() line and try again. |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |