PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 8th, 2000, 10:07 AM
tigertim tigertim is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 1999
Location: St.JOhn's, Newfoundland, Canada
Posts: 7 tigertim User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am looking for some one to give me a simple script that will allow a user to enter their email address and have it stored in a mysql database.

the table name is Email just show me where to put the other info.

Thanks in Advance
Tim

Reply With Quote
  #2  
Old March 8th, 2000, 10:40 PM
jmholm jmholm is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2000
Location: Chicago IL, USA
Posts: 16 jmholm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 27 m 54 sec
Reputation Power: 0
<?php
create a file named test.php3 with the everything between the ==== (don't include the ====) below in the file. You may have to fine tune the html form a bit.

Note the hidden "action" field. When the form is submitted (via POST) the field $action is available. Pass that to the addEmailToDb function and do an insert into the db.

If the $action field has no value (i.e., you just open the file in the browser) then it will execute the showForm() function, which will draw the form instead of inserting into the db.

===================================
function addEmailToDb($email_addr){
GLOBAL $PHP_SELF;
$HOSTNAME = "your_host";
$DB_LOGIN = "your_db_user";
$DB_PASSWD = "your_password";
$DB_NAME = "your_db_name";
$db = mysql_connect($HOSTNAME, $DB_LOGIN, $DB_PASSWD);
mysql_select_db($DB_NAME,$db);

$sql = "Insert INTO email values('$email_addr')";
$result = mysql_query($sql);
if (! $result) {
echo "an error occurred. email was not inserted into the db.";
} else {
echo "email was successfully inserted into the db.";
}

}

function showForm() {
echo "<html>n";
echo "<head>n";
echo "<title>Add Email</title>n";
echo "</head>n";
echo "<body bgcolor='#FFFFFF'>n";
echo "<table width=100% height=75%><tr><td><center>n";
echo "<table cellpadding=2><tr><td bgcolor=#b2b4f6><center>n";
echo "<table cellpadding=20><tr><td bgcolor=#ffffff><center>n";
echo "<form action='$PHP_SELF'>n";
echo "<input type=hidden name=action value=add_email>n";
echo "<table cellpadding=5 cellspacing=1>n";
echo "<tr><td>Password </td><td> <input type=password name=email_addr></td></tr>n";
echo "</table><p>n";
echo "<input type=submit value='Enter' default>n";
echo "<input type=reset value='Clear'><br>n";
echo "</form>n";
echo "</center></td></tr></table>n";
echo "</center></td></tr></table>n";
echo "</center></td></tr></table>n";
echo "</body>n";
echo "</html>n";
}

if ( $action == "admin") {
addEmailToDb($email_addr);
} else ( $action == "") {
showForm();
}

?>

=======================================
Hope this helps.

michael

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Input Script Help PLEASE!!!!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap