Jump to content

Winnetouch

Members
  • Posts

    4
  • Joined

  • Last visited

Everything posted by Winnetouch

  1. Thanks for the info. I'll look in to PHP mailer and maybe take a look at some tutorials.
  2. Ok... I'll be honest, I didn't understand half of what you said :P. I don't have a php.ini. All I have is a single index.php site because it's a single page site that scrolls up and down. This contact form is the only missing piece. The site is located here: http://viki.si/demosites/postaniskavt/index.php All I really understand up until now with php is how the form that I've created thus far is verified. I fail to understand how splitting the file in to 2 would make it function like it should. I understand that splitting the site in two would make it more menagable in the background but that's not really my concern for now. For now all I want is for the form that I've created up until now (with all the verification) to check if everything is entered correctly and send the email and send it only if everything is enetered correctly. I'll deal with the alert windows later when the form is functioning as it should. That's probably just a simple add on to the "if" statement anyway if I understand correctly. But I'm lost on how to form the if sentence to make the form check if every single information was entered correctly in to the form.
  3. Then let's limit the issue to make the contact form work as a contact form in the first place. How do I verify that everything was entered correctly and then send the email.
  4. Hello. A couple of weeks ago I concluded a couple of front end development courses and we only touched upon php coding. Since we didn't do much of it I used w3schools.com to learn some basics. I used the tutorial to make a contact form but I have a little problem. Currently the form is set (or rather was until I removed some code) to show anything that was entered in to the form on the site (basically like in this tutorial: https://www.w3schools.com/php/php_forms.asp). What I want the form to do is send the entered information to a predefined email address. But that's not all. It's going to be used on a singlepage website layout. I want the form to also show a prompt box that warns the user that either something went wrong or that the message was sent and reload the page back to the same position (I realise I need to use index#pageposition to do this but I don't know how to implement the link). Currently this only warns the user of what he did wrong (but not in a prompt box that something wrong happened) and reloads the page to the top. I'm a PHP noob (big noob), and I would appreciate if someone can help me out with this. Thank you :). <?php // define variables and set to empty values $nameErr = $emailErr = $genderErr = $websiteErr = ""; $name = $email = $gender = $comment = $website = ""; if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["name"])) { $nameErr = "Vpiši ime!"; } else { $name = test_input($_POST["name"]); if (!preg_match("/^[a-zA-Z ]*$/",$name)) { $nameErr = "Dovoljene so samo črke in presledki!"; } } if (empty($_POST["email"])) { $emailErr = "Vpiši email naslov!"; } else { $email = test_input($_POST["email"]); if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $emailErr = "Vpišite veljaven email naslov!"; } } if (empty($_POST["subject"])) { $subjectErr = "Vpiši naslov sporočila!"; } else { $subject = test_input($_POST["subject"]); } if (empty($_POST["message"])) { $messageErr = "Vpiši sporočilo!"; } else { $message = test_input($_POST["message"]); } } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } ?> <!DOCTYPE html> <html> <link rel="stylesheet" href="style.css" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet"> <meta name="kontakt"> <head> </head> <body> <div class="col-md-12"> <div class="form-area"> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>"> <br style="clear:both"> <h3>Piši nam</h3> <div class="form-group"> <input type="text" class="form-control" name="name" placeholder="Ime"> <span class="error">* <?php echo $nameErr;?></span> </div> <div class="form-group"> <input type="text" class="form-control" name="email" placeholder="Email"> <span class="error">* <?php echo $emailErr;?></span> </div> <div class="form-group"> <input type="text" class="form-control" name="subject" placeholder="Naslov"> <span class="error">* <?php echo $subjectErr;?></span> </div> <div class="form-group"> <textarea class="form-control" type="textarea" placeholder="Sporočilo" name=message rows="8"></textarea> <span class="error">* <?php echo $messageErr;?></span> </div> <input type="submit" class="btn btn-primary" name="submit" value="Submit"> <!--<button type="button" name="submit" class="btn btn-primary pull-right" value="Submit">Pošlji</button>--> </form> </div> </div> </body>
×
×
  • Create New...