mailingList tutorial
Posted: Mon May 21, 2012 2:38 pm
So I'm following the [youtube]http://www.youtube.com/watch?v=dQBFBuYyHVk[/youtube] tutorial and I've run into a bit of a problem. No matter what I do I can not get my signup.php form to insert into the database. I think I'm having a bit of a problem with the
I'm gonig to take an educated guess and say that
Anything else I should post? My add user function
mysql_select_db();function as no matter what I include for a parameter I get no errors on the page what so ever T_T
I'm gonig to take an educated guess and say that
mysql_connect('localhost','USERNAME','PASSWORD');is working as if I change USERNAME and PASSWORD in that line then I get errors such as can't connect to db.
Anything else I should post? My add user function
function add_user($firstname, $lastname, $email){ $firstname = mysql_real_escape_string($firstname); $lastname = mysql_real_escape_string($lastname); $email = mysql_real_escape_string($email); $result = mysql_query("INSERT INTO 'users' ('firstname','lastname','email') VALUES ('{$firstname}','{$lastname}','{$email}')"); return ($result !== false) ? true: false; }Code for my signup.php form
<?php include('core/init.inc.php'); if (isset($_POST['firstname'], $_POST['lastname'], $_POST['email'])){ $errors = array(); if (preg_match('/^[a-z]+$/i', $_POST['firstname'] === 0)){ $errors[] = 'Your first name should only be comprised of letters'; } if (preg_match('/^[a-z]+$/i', $_POST['lastname'] === 0)){ $errors[] = 'Your last name should only be comprised of letters'; } if (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) === false){ $errors[] = 'Your email address is not a valid format'; } if (empty($errors)){ add_user($_POST['firstname'], $_POST['lastname'], $_POST['email']); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml/DTD/xhtml1-strick.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>OpenKonga</title> <link rel="stylesheet" type="text/css" href="stylez.css" media="all" /> </head> <body> <div> <?php //echo print_r($errors); ?> </div> <div> <form action="" method="post"> <p> <label for="firstname">First Name: </label> <input type="text" name="firstname" id="firstname" /> </p> <p> <label for="lastname">Last Name: </label> <input type="text" name="lastname" id="lastname" /> </p> <p> <label for="eMail">eMail Address:</label> <input type="text" name="eMail" id="eMail" /> </p> <p> <input type="submit" value="Signup" /> </p> </form> </div> </body> </html>Can't think of anywhere else that the problem is O.o? I've followed the tutorial pretty much verbatim; only exception being I didn't perform the typos (maybe I did and don't know it).