Jump to content

Please help, I'm new with php


jogden614

Recommended Posts

I am trying to have my contact form for my website work correctly. I think I might of over did my php form, but I have a contact.php and a mailer.php. I am using netbeans for my coding. When I hit submit on my page after filling out the form, it goes to a pure blank page. Not a error or anything like that. I am not sure what is going on with it. My php is pretty simple. I don't think that I need all of the bottom of the html part. I have that saved as contact.php. I also have my contactus.html that has the same thing in it. I read that you are suppose to have 2 types of php files. I wasn't too sure of that. I know I might sound like an idiot, but I am new to PHP. I am trying to learn it. I know HTML/CSS, but I want to learn PHP also. Any help would be a blessing.

 It is also saying that my echo "theResults"; is an error right before my end php tag. Not sure why. I thought that it was fine to do just echo "theResults";

<?php
$emailSubject = 'Customer has a questions!';
$webmaster = $body = <<<EOD
<br><hr><br>
Name: $name <br>;
Email: $email <br>;
Message: $message <br>
EOD;
$headers = "From: $email\r\n";
$headers = "Content-type: text/html\rn\";

<a href="mailto:" data-ipb="nomediaparse" data-cke-saved-href="mailto:" jogden614@yahoo.com'"="">$success = mail($webMaster, $emailSubject, $body, $headers);

<a href="mailto:" data-ipb="nomediaparse" data-cke-saved-href="mailto:" jogden614@yahoo.com'"="">$theResults: <<<EOD
    Your e-mail has been sent and I will get back to you as soon as I can.
EOD;
echo "$theResults";
?>
<!doctype-HTML>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=700">
<title>Contact Us</title>
<link rel="stylesheet" href="css/main.css"/>
<link rel="stylesheet" media="print" href="css/print.css"/>
</head>
<body>
<img src="images/sitetitle.png" alt="Top Notch Web Creations" id="st"/>
<img src="images/logo.png" alt="TN"/>
<nav>
   <ul style="text-align:center">
     <li><a href="index.html" >HOME</a></li>
     <li><a href="about.html" >ABOUT</a></li>
     <li><a href="gallery.html" >GALLERY</a></li>
     <li><a href="blog.html" >BLOG</a></li>
     <li><a href="contactus.html" class="current" >CONTACT US</a></li>
      </ul>
</nav>
<header>Contact Us</header>
<p> If you would like to contact me or give me feedback please use the form
below. I check my emails very often and I will get back to you as soon as I can.
I usually reply back to the email no later than 48 hours.
If it does happen then it is becuase their is a high volume of emails coming
in at the time, but you should recieve an email within 2 days after.
If you would like a quicker response, please email me at Jogden614@yahoo.com.
</p>
<form class="email" action="mailer.php" method="post">

<p class="info">
<label for="name">Name</label>
<input type="text" name="name" placeholder="Full Name" required/>
</p>
<p class="info">
<label for="Email">Email</label>
<input type="text" name="email" placeholder="Email" required/>
</p>
<p class="info">
<label for="Site">Website</label>
<input type="text" name="site" placeholder="Website"/>
</p>
<p class="info">
<label for="subject">Subject</label>
<input type="text" name="subject" placeholder="Subject"/>
</p>
<p class="message" id="box">
<textarea name="Text" placeholder="Message" rows="15" cols="40" required/></textarea>
</p>
<p class="submit">
<input type="submit" value="Send"/>
</p>
</form>
</body>
<footer style="text-align:center">Copyright ©2014 TopNotchWebCreations, All Rights Reserved
<img src="images/linkedin.png" height="20" width="20" id="li"></a>
</footer>
</html>

Edited by jogden614
Link to comment
Share on other sites

#1 - please use the proper tags to enclose your code on this site, as on other sites.  You can find them in the rules of the forum at the top of the page.

 

#2 - when developing in php, ALWAYS  turn on php's error checking.  Look it up in the manual and you'll learn about a valuable resource.

 

#3 - I see at least two errors that will show up as soon as you turn on error checking,  This is why you got a blank page - your script failed but did not display the errors that were occurring.

Link to comment
Share on other sites

Ginerjm. What do you mean with #1. I looked through it and I am not sure what I did wrong as far as forum rules. Netbean already has the error warnings automatic for my script. I will have to do some more research just to make sure that it is on. The only error that came up was with my echo "theresults"; 

What errors do you see? Could you help me out a little? I am new with PHP and I just want to make my contact form work properly.

Link to comment
Share on other sites

As for #1 - At the top of the page click on Rules and TOS.    Go to Forum Guidelines.  Read all of them, but most specifically #4.

 

Warnings - I have no idea what netbeans gives you but apparently no proper php error checking.  I'll post it here for you since you apparently didn't research the php manual.

 

 

 error_reporting(E_ALL | E_NOTICE);
 ini_set('display_errors', '1');

 

Place at the beginning of any script you are developing.

 

Errors?  So many.....

 

Major error is your use of php inside (or should I say outside of php) html code.  You can't start a heredocs block in the middle of html which you do.  Also I searched the manual for alternate syntaxes and could not find one that supports the following:

 

$theResults: <<<EOD

 

The only syntax uses an = sign, not a colon.  If this is working for you, then perhaps the authors of the manual need to correct themselves.

And while I'm discussing the chunk of code (html) you are not in php mode here so how do you expect the echo "$theResults"; to work?  BTW - you don't need the quotes here.

 

I'm sure once you turn on error checking as above you'll get plenty of messages in place of the blank page you currently receive.

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.