Jump to content

Issues with displaying if else echo statement in contact page..


NickP

Recommended Posts

Here's the code, this is the PHP in my html contacts page (that IS in fact saved with a PHP extension): 
 

<div class = "centercontainer">
 
<form method="post" action="NickParkerPhotoContact.php">
<label class = "labelwithmargin">Email: [email protected]</label>
<label>Please use the form below:</label>
<br>
<label class = "labelwithmargin">Name*</label>
    <input name="name" placeholder="Type Here">
 
<label class = "labelwithmargin">Number</label>
    <input name="number" placeholder="Type Here">
            
    <label class = "labelwithmargin">Email*</label>
    <input name="email" type="email" placeholder="Type Here">
            
    <label class = "labelwithmargin">Message</label>
    <textarea name="message" placeholder="Type Here"></textarea>
           
    <input id="submit" name="submit" type="submit" value="Submit">
 
<?php
if ($_POST['submit']) {
$name = $_POST['name'];
$number = $_POST['number'];
   $email = $_POST['email'];
   $message = $_POST['message'];
   $from = 'From: NickParkerPhoto website'; 
   $to = '[email protected]'; 
   $subject = 'Message from website';
 
   $body = "From: $name\n Number: $number\n E-Mail: $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 and try again!</p>'; 
     }
}
?>
</form>

And the issue is I keep seeing this in my web page, which means my code is not working with the submit button I created.. :

15211400683_415c25ede5_o.jpg

I'm a complete newby to PHP and have been learning it mostly just for this contact page, but learning that it is a server only-widely accepted language I'm pretty hyped to know anything about it... 

Thanks! 

Nick P. 

 

Right off i see a mistake

 

change this:

if (mail ($to, $subject, $body, $from))) {

to this:

if (mail ($to, $subject, $body, $from)) {

Besides that, obviously php is not parsing correctly, first make sure xampp is configured and working.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.