Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Ezilon Directory   ClickBooth Network   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 07-28-2006, 03:07 AM   #1 (permalink)
Inactive
 
Join Date: 07-04-06
Location: Belfast, Northern Ireland
Posts: 11
iTrader: 0 / 0%
Latest Blog:
None

Kinetic_Mix is liked by many
Simple PHP / Mysql form !!

I am looking some PHP help with a simple email signup script !

I have created a mysql database with the following fields : ID, Name, Email and MobileNo

What I want to do is have a form on my website which will collect all these details and then validate the data to make sure that all fields have been filled in with the correct data, however Mobile number is not a compulsory field so does not have to be filled in. When the data has been validated and is correct then I want to add this record to my database called, newsletter in a table called signup. Once this has been done then you will be directed back to the same page you signup from.

I know this is a simple thing to do, but I have never done any PHP coding before and I am looking for some guidance on how to create the script or if anyone can post some code that would do what I am needing then I would be grateful !
Kinetic_Mix is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 07-28-2006, 01:18 PM   #2 (permalink)
Potato Monster
 
Immo's Avatar
 
Join Date: 03-26-04
Location: Chester, England
Posts: 3,869
iTrader: 0 / 0%
Immo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest orderImmo is a web professional of the highest order
Send a message via ICQ to Immo Send a message via AIM to Immo Send a message via MSN to Immo Send a message via Yahoo to Immo Send a message via Skype™ to Immo
Not tested the below script, I just wrote it but it should work. Make sure you have ID in the database set as auto_increment. Also make sure the form text box names are "email", "name", "mobile".

Any errors let me know and I will fix it.

<?php
if (isset($_POST) {
if ($_POST['email'] && $_POST['name'] && $_POST['mobile'] != "") {
$sql = mysql_query("SELECT * FROM `table_name` WHERE `NAME` = " . $_POST['email'] . " LIMIT 1");
$rows = mysql_num_rows($sql);
if ($rows == "1") {
echo ?>
<p>Sorry that email address has been used to register here before, please try another.</p>(INSERT FORM AGAIN HERE)
<?php ;
}
else {
$ins = mysql_query("INSERT INTO `table_name` (`ID`, `Name`, `Email`, `MobileNo`) VALUES ('', '" . $_POST['name'] . "', '" . $_POST['email'] . "', '" . $_POST['mobile'] . "'));
echo ?>
<p>Thanks for registering... You have been added to our database.</p>
<?php ;
}
}
else {
echo ?><p>You did note complete all fields in the form please try again.</p> (INSERT FORM AGAIN)
<?php ;
}
else {
echo ?>
(INSERT FORM HERE)
<?php ;
}
?>
__________________
I have become death, destroyer of worlds.
Immo is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use Ajax for a simple web form? ladan Coding Forum 3 01-18-2007 03:24 AM
PHP/MySQL Login Form Help Limit Coding Forum 3 10-02-2004 06:34 AM
help with a very simple php form games_master Coding Forum 1 06-09-2004 10:25 AM
simple form fillout problem.... a1c1e19 Coding Forum 9 04-08-2004 01:00 PM
VERY SIMPLE php /mysql script needed. will pay craigj Coding Forum 1 01-05-2004 09:00 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 01:25 AM.
© Copyright 2008 V7 Inc