Jump to content


Photo

Email Submitted script


  • Please log in to reply
7 replies to this topic

#1 jeliot

jeliot
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 02 April 2006 - 07:14 PM

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

#2 play_

play_
  • Staff Alumni
  • Advanced Member
  • 717 posts

Posted 02 April 2006 - 07:20 PM

post the code yo.
regex.kat.sh --- regex library
u.kat.sh ---- url shortener
tabbit.org ---- tabbed pastebin

#3 jeliot

jeliot
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 02 April 2006 - 09:31 PM

[!--quoteo(post=360950:date=Apr 2 2006, 02:20 PM:name=play_)--][div class=\'quotetop\']QUOTE(play_ @ Apr 2 2006, 02:20 PM) View Post[/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

#4 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 02 April 2006 - 09:37 PM

{
$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

}


#5 jeliot

jeliot
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 02 April 2006 - 11:21 PM

[!--quoteo(post=360981:date=Apr 2 2006, 04:37 PM:name=alpine)--][div class=\'quotetop\']QUOTE(alpine @ Apr 2 2006, 04:37 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
{
$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

}
[/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

#6 play_

play_
  • Staff Alumni
  • Advanced Member
  • 717 posts

Posted 03 April 2006 - 02:29 AM

{
$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
}

}
regex.kat.sh --- regex library
u.kat.sh ---- url shortener
tabbit.org ---- tabbed pastebin

#7 jeliot

jeliot
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 03 April 2006 - 02:59 AM

[!--quoteo(post=361075:date=Apr 2 2006, 09:29 PM:name=play_)--][div class=\'quotetop\']QUOTE(play_ @ Apr 2 2006, 09:29 PM) View Post[/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

#8 txmedic03

txmedic03
  • Members
  • PipPipPip
  • Advanced Member
  • 313 posts
  • LocationCall, TX, USA

Posted 03 April 2006 - 08:03 AM

Never post your usernames/passwords to anything on a publicly viewable website.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users