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: Nick@NickParkerPhoto.com</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 = 'NickParkerPhoto@gmail.com'; 
   $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. 

 

Edited by NickP
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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