Jump to content

Email Submitted script


jeliot

Recommended Posts

[!--quoteo(post=360950:date=Apr 2 2006, 02:20 PM:name=play_)--][div class=\'quotetop\']QUOTE(play_ @ Apr 2 2006, 02:20 PM) [snapback]360950[/snapback][/div][div class=\'quotemain\'][!--quotec--]
post the code yo.
[/quote]

<?php
$db_host = "mysql";
$db_user = "jeliot";
$db_pwd = "8013301";
$db_name = "email";
mysql_connect($db_host, $db_user, $db_pwd);
mysql_select_db($db_name);
if (!isset($_POST['submit'])) {
?>
<img src="images/email_list_logo.jpg" width="500" height="204">
<form action="" method="post">
Name: <input type="text" name="name" size="50"><br>
Email: <input type="text" name="email" size="50"><br>
<input type="submit" name="submit" value="Submit!">
</form>
<?php
} else {
$name = $_POST['name'];
$email = $_POST['email'];
$query = "INSERT INTO email_list (name,email) VALUES ('".$name."','".$email."')";
$result = mysql_query($query) or die(mysql_error()); // this performs the actual query.
}
?>

sorry .............brain fart..............I'm still working on cleaner less complicated script but every time I mess with it.......it either won't display or won't populate the db with any data

also is there a way to get this form to open in a new smaller browser window with a php script or do I have to implement java code
Link to comment
Share on other sites

[code]
{
$name = $_POST['name'];
$email = $_POST['email'];
$query = "INSERT INTO email_list (name,email) VALUES ('".$name."','".$email."')";
$result = mysql_query($query) or die(mysql_error()); // this performs the actual query.

// start visual
if($result)
{
print "This is a message displayed upon query success!";
}
else
{
print "This is a message displayed due to insert failure";
}
// end visual

}
[/code]
Link to comment
Share on other sites

[!--quoteo(post=360981:date=Apr 2 2006, 04:37 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ Apr 2 2006, 04:37 PM) [snapback]360981[/snapback][/div][div class=\'quotemain\'][!--quotec--]
[code]
{
$name = $_POST['name'];
$email = $_POST['email'];
$query = "INSERT INTO email_list (name,email) VALUES ('".$name."','".$email."')";
$result = mysql_query($query) or die(mysql_error()); // this performs the actual query.

// start visual
if($result)
{
print "This is a message displayed upon query success!";
}
else
{
print "This is a message displayed due to insert failure";
}
// end visual

}
[/code]
[/quote]


Thanks that worked great............now I'll really test ya.....wink....wink

how about code that will read the data fields and display "You are already on the mailing List" if it finds the same data in the db
Link to comment
Share on other sites

{
$name = $_POST['name'];
$email = $_POST['email'];

$check = "SELECT * FROM email_list WHERE name='$name' and email='$email'";
$check_result = mysql_query($check);
$num = mysql_num_rows($check_result);
if (num > 0) {
echo "You are already on the mailing list";
} else {
$query = "INSERT INTO email_list (name,email) VALUES ('".$name."','".$email."')";
$result = mysql_query($query) or die(mysql_error()); // this performs the actual query.

// start visual
if($result)
{
print "This is a message displayed upon query success!";
}
else
{
print "This is a message displayed due to insert failure";
}
// end visual
}

}
Link to comment
Share on other sites

[!--quoteo(post=361075:date=Apr 2 2006, 09:29 PM:name=play_)--][div class=\'quotetop\']QUOTE(play_ @ Apr 2 2006, 09:29 PM) [snapback]361075[/snapback][/div][div class=\'quotemain\'][!--quotec--]
{
$name = $_POST['name'];
$email = $_POST['email'];

$check = "SELECT * FROM email_list WHERE name='$name' and email='$email'";
$check_result = mysql_query($check);
$num = mysql_num_rows($check_result);
if (num > 0) {
echo "You are already on the mailing list";
} else {
$query = "INSERT INTO email_list (name,email) VALUES ('".$name."','".$email."')";
$result = mysql_query($query) or die(mysql_error()); // this performs the actual query.

// start visual
if($result)
{
print "This is a message displayed upon query success!";
}
else
{
print "This is a message displayed due to insert failure";
}
// end visual
}

}
[/quote]


I gave the script a shot with a name and email already in the db and it went through successfully
Thanks for the input i have a starting point atleast
let me know if you find any thing i should try changing
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.