Jump to content

Archived

This topic is now archived and is closed to further replies.

jeliot

Email Submitted script

Recommended Posts

I want to add a statement to print "Your Email Has Been Submitted" into my email form but I'm having trouble
ANY SUGGESTIONS

Thanks

Share this post


Link to post
Share on other sites
[!--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

Share this post


Link to post
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]

Share this post


Link to post
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

Share this post


Link to post
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
}

}

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
Never post your usernames/passwords to anything on a publicly viewable website.

Share this post


Link to post
Share on other sites

×

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.