Jump to content

jazza96

Members
  • Posts

    17
  • Joined

  • Last visited

Everything posted by jazza96

  1. If I use MYSQLi, do I just add the 'I' after the MYSQL?
  2. Hi Firstly I am new to programming so go easy on me I am building a page where the user inputs text into a table called 'products'. This is the code I am using: $productname=$_POST['productname']; $productprice=$_POST['productprice']; $productpostage=$_POST['productposage']; $productquick=$_POST['productquick']; $productdescription=$_POST['productdescription']; $productdelivery=$_POST['productdelivery']; mysql_connect('localhost', 'username', 'password') or die(mysql_error()); mysql_select_db('Kanga') or die(mysql_error()); mysql_query("INSERT INTO 'product' VALUES ('$productname', '$productprice', '$productpostage', '$productquick', '$productdescription', '$productdelivery')"); print "$productname has been added to the database."; ?> When I press the submit button on the form, I get "Hello world(this is what i entered into the productname field) has been added to the database." I am using phpmyadmin, so should all the data that is submitted show up in there? Thanks Jarrod
  3. Yes, I put an email address in the $from variable and it still didn't work.
  4. No, I have not. It is just on my localhost server (MAMP). <?php error_reporting(-1); ini_set('display_errors', 'On'); $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'email'; $to = 'email'; /* I have my different email in these fields. */ $subject = "Landing page"; $body = "From: $name\n email: $email\n message:\n $message"; ?> <?php if(mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent</p>'; }else{ echo '<p>Something went wrong, go back!</p>'; } ?> <div class="modal fade" id="contact" role="dialog"> <div class=" modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h2>Contact us</h2> <p>Do you have a question, suggestion or comment?</p> </div> <div class="modal-body"> <form method="post" action="index.php"> <div class="form-horizontal"> <label for="Name">Your Name</label> <input type="text" class="form-control" name="name" placeholder="Name"> <label for="Email">Your Email</label> <input type="Email" class="form-control" name="email" placeholder="Email"> <label for="Message">Message</label> <textarea class="form-control" name="message" placeholder="Message"></textarea> <input type="submit" name="submit" value="Send" action="index.php"></input> </form> </div> </div> <div class="modal-footer"> <a class="btn btn-default" data-dismiss = "modal">Close</a> </div> </div> </div>
  5. Yes I did.
  6. It worked!! Thanks One other problem is that the message is not sending now to my nominated email address.
  7. Do you get the error messages after the form submits? Note: to avoid seeing the errors before the form is submitted, move the initial variable declarations inside the construct that tests whether the form was submitted: <?php if ($_POST['submit']){ $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Jarrod'; $to = 'email'; $subject = "Landing page"; $body = "From: $name\n Email: $email\n Message:\n $message"; if(mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; }else{ echo '<p>Something went wrong, go back!</p>'; } } ?> The errors are appearing when I refresh the page. I put in that code and I am no longer getting this error: Notice: Undefined index: submit in /Applications/MAMP/htdocs/Jumbotron/index.php on line 135 but I am still getting the other error's Notice: Undefined index: name in /Applications/MAMP/htdocs/Jumbotron/index.php on line 124 Notice: Undefined index: email in /Applications/MAMP/htdocs/Jumbotron/index.php on line 125 Notice: Undefined index: message in /Applications/MAMP/htdocs/Jumbotron/index.php on line 126
  8. I am getting 4 undefined errors. Notice: Undefined index: name in /Applications/MAMP/htdocs/Jumbotron/index.php on line 124 Notice: Undefined index: email in /Applications/MAMP/htdocs/Jumbotron/index.php on line 125 Notice: Undefined index: message in /Applications/MAMP/htdocs/Jumbotron/index.php on line 126 Notice: Undefined index: submit in /Applications/MAMP/htdocs/Jumbotron/index.php on line 135
  9. Tried it and it didn't work unfortunately
  10. I have added an action to the form. <div class="modal-body"> <form method="post" action="index.php"> <div class="form-horizontal"> <label for="Name">Your Name</label> <input type="text" class="form-control" id="Name" placeholder="Name"> <label for="Email">Your Email</label> <input type="Email" class="form-control" id="Email" placeholder="Email"> <label for="Message">Message</label> <textarea class="form-control" id="Message" placeholder="Message"></textarea> <button type="button" class="btn btn-primary">Send</button> </form> </div> </div> The php code is on the index.php file.
  11. Yes, I did that on purpose because I didn't want my email address public.
  12. Hi I am trying to build a contact form and my form isnt sending. Here is my code. (its in a modal window)(I have my email address in the $to variable in the code) <?php $name = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $from = 'From: Jarrod'; $to = 'email'; $subject = "Landing page"; $body = "From: $name\n Email: $email\n Message:\n $message"; ?> <?php if ($_POST['submit']){ if(mail ($to, $subject, $body, $from)) { echo '<p>Your message has been sent!</p>'; }else{ echo '<p>Something went wrong, go back!</p>'; } } ?> <div class="modal fade" id="contact" role="dialog"> <div class=" modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h2>Contact us</h2> </div> <div class="modal-body"> <form method="post" action="index1.php"> <div class="form-horizontal"> <label for="Name">Your Name</label> <input type="text" class="form-control" id="name" placeholder="Name"> <label for="Email">Your Email</label> <input type="Email" class="form-control" id="email" placeholder="Email"> <label for="Message">Message</label> <textarea class="form-control" id="message" placeholder="Message"></textarea> <input type="submit" value="Send">Send</button> </form> <div class="modal-footer"> <a class="btn btn-default" data-dismiss = "modal">Close</a> </div> </div> </div> </div>
  13. Thank you so much.
  14. Hi I am currently using bootstrap to design a landing page. I want to add a contact us form and I need to use a text area for long messages. When I use it with bootstrap it just appears as a single line and not a large field. How can I style just 1 field instead of all of them? This is my HTML code. <form> <div class="form-horizontal"> <label for="Name">Your Name</label> <input type="text" class="form-control" id="Name" placeholder="Name"> <label for="Email">Your Email</label> <input type="Email" class="form-control" id="Email" placeholder="Email"> <label for="Message">Message</label> <input type="textarea" class="form-control" id="Message" placeholder="Message"> </form>
  15. Thanks for those tips. I have started a new project where I am building a social networking site like facebook.
  16. Hi I just finished this tutorial('http://www.startutorial.com/articles/view/php-crud-tutorial-part-3/) and everything was working fine until I decided to add last names to the application. I got everything working on all the other pages except the Update page. This is my php code. d = $_REQUEST['id']; } if ( null==$id ) { header("Location: index.php"); } if ( !empty($_POST)) { // keep track validation errors $nameError = null; $lastError = null; $emailError = null; $mobileError = null; // keep track post values $name = $_POST['name']; $last = $_POST['last']; $email = $_POST['email']; $mobile = $_POST['mobile']; // validate input $valid = true; if (empty($name)) { $nameError = 'Please enter Name'; $valid = false; } $valid = true; if (empty($last)) { $lastError = 'Please enter last name'; $valid = false; } if (empty($email)) { $emailError = 'Please enter Email Address'; $valid = false; } else if ( !filter_var($email,FILTER_VALIDATE_EMAIL) ) { $emailError = 'Please enter a valid Email Address'; $valid = false; } if (empty($mobile)) { $mobileError = 'Please enter Mobile Number'; $valid = false; } // update data if ($valid) { $pdo = Database::connect(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "UPDATE customers set name = ?, last = ?, email = ?, mobile =? WHERE id = ?"; $q = $pdo->prepare($sql); $q->execute(array($name, $last,$email,$mobile,$id)); Database::disconnect(); header("Location: index.php"); } } else { $pdo = Database::connect(); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $sql = "SELECT * FROM customers where id = ?"; $q = $pdo->prepare($sql); $q->execute(array($id)); $data = $q->fetch(PDO::FETCH_ASSOC); $name = $data['name']; $last = $data['last']; $email = $data['email']; $mobile = $data['mobile']; Database::disconnect(); } ?> When I hit Update it is directing me to a white screen instead of the index.php page.
  17. Thanks for those tips. I am currently building a basic CRUD program and I am learning quite a lot just from building something..
  18. Yes, here it is on Amazon. http://www.amazon.com/Learning-MySQL-JavaScript-HTML5-Step-/dp/1491949465/ref=sr_1_1?s=books&ie=UTF8&qid=1419850564&sr=1-1&keywords=php Have you heard bad things about the book?
  19. Hello! My name is Jarrod and I am 18 and live in Australia. I have only just started coding in the past 3 months and PHP is my first language. I have just completed the O'Riley book 'PHP, MYSQL, Javascript, CSS and HTML5'.
×
×
  • 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.