home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2801
Discussions: 188,385, Posts: 2,243,510, Members: 232,615
Old February 18th, 2003, 12:38 AM   Digg it!   #1 (permalink)
Ultimate Member
 
embj's Avatar
 
Join Date: Dec 2002
Location: Fayetteville, NC
Posts: 1,385
Send a message via AIM to embj Send a message via MSN to embj Send a message via Yahoo to embj
PHP Form

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!

embj is offline   Reply With Quote
Old February 18th, 2003, 02:09 AM     #2 (permalink)
Ultimate Member
 
Praetorian's Avatar
 
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.
Praetorian is offline   Reply With Quote
Old February 18th, 2003, 02:14 AM     #3 (permalink)
Ultimate Member
 
embj's Avatar
 
Join Date: Dec 2002
Location: Fayetteville, NC
Posts: 1,385
Send a message via AIM to embj Send a message via MSN to embj Send a message via Yahoo to embj
Ok, thanks. I will look at it tomorrow when I have a chance.

embj is offline   Reply With Quote
Old February 18th, 2003, 06:14 PM     #4 (permalink)
Ultimate Member
 
embj's Avatar
 
Join Date: Dec 2002
Location: Fayetteville, NC
Posts: 1,385
Send a message via AIM to embj Send a message via MSN to embj Send a message via Yahoo to embj
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.
embj is offline   Reply With Quote
Old February 18th, 2003, 06:43 PM     #5 (permalink)
Ultimate Member
 
embj's Avatar
 
Join Date: Dec 2002
Location: Fayetteville, NC
Posts: 1,385
Send a message via AIM to embj Send a message via MSN to embj Send a message via Yahoo to embj
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.
embj is offline   Reply With Quote
Old February 18th, 2003, 07:10 PM     #6 (permalink)
Ultimate Member
 
Praetorian's Avatar
 
Join Date: Oct 2001
Location: Arizona
Posts: 2,538
Just type this:

PHP Code:
echo "<div align=\"center\">CENTERED TEXT</div>"
Praetorian is offline   Reply With Quote
Old February 18th, 2003, 07:21 PM     #7 (permalink)
Ultimate Member
 
embj's Avatar
 
Join Date: Dec 2002
Location: Fayetteville, NC
Posts: 1,385
Send a message via AIM to embj Send a message via MSN to embj Send a message via Yahoo to embj
Thanks, again. Do you know the answer to my other question?
embj is offline   Reply With Quote
Old February 18th, 2003, 07:40 PM     #8 (permalink)
Ultimate Member
 
Praetorian's Avatar
 
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">&nbsp;
</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.
Praetorian is offline   Reply With Quote
Old February 18th, 2003, 08:10 PM     #9 (permalink)
Ultimate Member
 
embj's Avatar
 
Join Date: Dec 2002
Location: Fayetteville, NC
Posts: 1,385
Send a message via AIM to embj Send a message via MSN to embj Send a message via Yahoo to embj
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: .
embj is offline   Reply With Quote
Old February 19th, 2003, 07:55 PM     #10 (permalink)
Ultimate Member
 
Praetorian's Avatar
 
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.
Praetorian is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may 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 Off
Pingbacks are On
Refbacks are Off

Most Active Discussions
Is It Just Me? (2897)
CPU wont boot (6)
3-days in and no threads about Gaza (160)
The United States Debt (20)
I think I just killed my computer w.. (24)
hp compaq nc6000 problems (139)
Upgrading RAM (5)
Folderchat Weekday thread (442)
Antec 300 bulk purchase? (11)
Recent Discussions
Problem With LightScribe DVD Dr.. (0)
CPU wont boot (6)
GLaDOS is up. (3)
HP notebook reinstall Vista NO .. (5)
Building a gaming computer advi.. (4)
hp compaq nc6000 problems (139)
Folderchat Weekday thread (442)
Creative T-3000 Subwoofer (3)
ACPI controller halt on boot (2)
Blackberry Storm, Gears of War .. (1)
Core 2 Quad Q9550 system (3)
COWBOOM Ripoff! Used Laptop w/$.. (4)


All times are GMT -4. The time now is 10:49 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28