Jump to content

StevenJacobs

Members
  • Posts

    22
  • Joined

  • Last visited

StevenJacobs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. sure. well i used ur original code matched with love2code and its working nice. if i add the section you gave me with the echo it doesnt work, but this is what it gives me: SELECT `EMAIL` FROM `subscribers` WHERE `EMAIL` = ''art.stevenjacobs@yahoo.com''
  2. Nevermind! i solved it buy doing what you said in your edit, heres what worked: $Result1 = mysql_query($insertSQL,$subscribers); $insert = mysql_affected_rows(); if(!$Result1) { echo "Username and/or password already in use."; } else { echo "You have successfully registered."; } Its working perfectly now! Again thank you everybody! i cant thank you enough for all the help!
  3. yea i just tried it, unless if im doing something wrong it is not working. Its now giving this error if i type in a new email or a email already in the database. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/steven/public_html/testing.php on line 63 Username and/or password already in use. Line 63 would be this part of the code you gave me: $rows = mysql_num_rows($Result1);
  4. yeah no problem.. i used one of the first codes that jazzman gave me. and its working like a charm now. <?php include ('Connections/subscribers.php'); date_default_timezone_set('America/Chicago'); if (isset($_POST['Submit'])) { if ($_POST['email'] != "") { $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors = "$email is <strong>NOT</strong> a valid email address.<br/><br/>"; } } else { $errors .= 'Please enter your email address.<br/>'; } if (isset($errors)) { echo '<div style="color: red">' . $errors . '<br/></div>'; return false; } if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $insertSQL = sprintf("INSERT INTO subscribers (EMAIL) VALUES (%s)", GetSQLValueString($_POST['email'], "text")); mysql_select_db($database_subscribers, $subscribers); $Result1 = mysql_query($insertSQL, $subscribers) or die(mysql_error()); } } else { ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form1" method="POST"> Email Address: <br/> <input type="text" name="email" value="<?php echo $_POST['email']; ?>" size="50"/> <br/><br/> <input type="submit" name="Submit" /> <input type="hidden" name="MM_insert" value="form1" /> </form> <?php } ?>
  5. awesome! that worked!.. lol i feel so stupid, that was very simple.. one question tho, how do i change the message that comes up? its saying: Duplicate entry 'art.stevenacobs@yahoo.com' for key 'EMAIL' Thank everybody again for all the help, i really appreciate it!
  6. ok well when i comment that section it stops giving any errors. it also enters valid emails into the database now, but back to the problem, it allows same emails to keep being entered.
  7. I used his last one (reply #17) modified with reply # 27
  8. Still no luck, didnt change anything.. just saw your edit a few replys ago. not sure what you mean by what action im getting. but after i hit submit, its going to a blank page with the following error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'art.stevenacobs@yahoo.com'')' at line 1
  9. Ok i just saw it, but im not to sure what exactly your saying i should change.
  10. Sure. <?php include ('Connections/subscribers.php'); date_default_timezone_set('America/Chicago'); if (isset($_POST['Submit'])) { if ($_POST['email'] != "") { $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $errors = "$email is <strong>NOT</strong> a valid email address.<br/><br/>"; } } else { $errors .= 'Please enter your email address.<br/>'; } if (isset($errors)) { echo '<div style="color: red">' . $errors . '<br/></div>'; return false; } if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { if (PHP_VERSION < 6) { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; } $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? doubleval($theValue) : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { mysql_select_db($database_subscribers, $subscribers); $check_email = sprintf("SELECT `EMAIL` FROM `subscribers` WHERE `EMAIL` = '%s'", GetSQLValueString($_POST['email'], "text")); $result = mysql_query($check_email, $subscribers) or die(mysql_error()); if(mysql_num_rows($result) > 0) { echo 'Sorry, but this email has beed already taken'; return false; } $insertSQL = sprintf("INSERT INTO subscribers (`EMAIL`) VALUES ('%s')", GetSQLValueString($_POST['email'], "text")); echo $insertSQL; exit; $Result1 = mysql_query($insertSQL, $subscribers) or die(mysql_error()); } } else { $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" name="form1" method="POST"> Email Address: <br/> <input type="text" name="email" onfocus="if (this.value == 'Email...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Email...';}" value="<?php echo $_POST['email']; ?>Email..." size="50"/> <br/><br/> <input type="submit" name="Submit" /> <input type="hidden" name="MM_insert" value="form1" /> </form> <?php } ?>
  11. still didnt change anything. and i only have two columns. ID and EMAIL.
  12. well that took away the first error, but still not inserting valid emails. now its just saying: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'art.stevenacobs@yahoo.com''' at line 1
  13. oh thats no problem-oh man. thats exactly what i was trying to work with early. but its giving an error code and not inserting valid emails. Notice: Undefined variable: editFormAction in /home/steven/public_html/testing.php on line 59 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'art.stevenjacobs@yahoo.com''' at line 1 58 if (isset($_SERVER['QUERY_STRING'])) { 59 $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); 60 }
  14. Sorry to bug you, u have already helped me out tremendously. but i have one last question. how can i validate that the email isn't in the database, to prevent multiple same emails being entered?
×
×
  • 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.