Some PHP help!

Discuss computers and technology here.
User avatar
Mugen9s
Global moderator
Posts: 1078
Joined: Sun Jun 01, 2008 6:35 pm
Are you a spam bot?: NO
Location: United Kingdom
Contact:

Some PHP help!

Postby Mugen9s » Sat Sep 20, 2008 7:22 pm

:hmm:
I need to make a site where the user can send a form to my website i have a problem. when the user submits the for and is re-routed to a successful sending page i get the page but some of the php coding shows up -
Untitled.jpg
Untitled.jpg (18.13 KiB) Viewed 4556 times

Heres the coding (not all of it is used to save space, only the important stuff) -

Code: Select all

<?php

/* Subject and Email Variables */

   $emailSubject = 'RecycleGBForm';
    $webMaster = 'rurmel_miah@hotmail.com';
   
/* Gathering Data Variables */

   $emailField = $_POST['email'];
    $nameField = $_POST['name'];
    $phoneField = $_POST['phone'];
    $commentsField = $_POST['comments'];
    $newsletterField = $_POST['newsletter'];
   
    $body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number: $phone <br>
Comments: $commments <br>
Newsletter: $newsletter <br>
EOD;
   
   $headers = "From: $email\r\n";
   $headers .= "Content-type: text/html\r\n";
   $success = mail($webMaster, $emailSubject, $body, $headers);
   
/* Results rendered as HTML */

   $theResults = <<<EOD


Anyone help me out please and thank you in advance :k7
R.I.P Rudy. You will always remain in our hearts and prayers.

User avatar
Rudy
Caiman Moderator
Posts: 2704
Joined: Sat May 31, 2008 7:42 pm
Location: Belgium
Contact:

Re: Some PHP help!

Postby Rudy » Sat Sep 20, 2008 7:32 pm

I think you mixed html and php! :shock: Never do that!
You have to write php code between <? and ?> and outside that you can write html
I am not a specialist on php, but I think you could write such easy code even in html only

Kinks
Posts: 640
Joined: Sat May 31, 2008 7:59 pm

Re: Some PHP help!

Postby Kinks » Sun Sep 21, 2008 12:16 pm

:huh?:
R.I.P Rudy....Heaven has one more angel and the night sky has one more star, the biggest out there. I love you xxx

User avatar
Mugen9s
Global moderator
Posts: 1078
Joined: Sun Jun 01, 2008 6:35 pm
Are you a spam bot?: NO
Location: United Kingdom
Contact:

Re: Some PHP help!

Postby Mugen9s » Sun Sep 21, 2008 12:59 pm

This isnt the entire code but where it says -

Code: Select all

/* Results rendered as HTML */

   $theResults = <<<EOD


After that I put the HTML code that will come up to say "you have successfully sent the form etc.." and then end the code with

Code: Select all

EOD;
but I still get those php scripting which I dont want the user to see...

Code: Select all

Email: $email <br>
Name: $name <br>
Phone Number: $phone <br>
Comments: $commments <br>
Newsletter: $newsletter <br>

This should be the information that is sent to my email adress, so I can see that the user has filled out so and so their name, phone, email...
Thats where I am stuck the script should n't show up on the page.


'BTW I am using adobe dreamweaver'
R.I.P Rudy. You will always remain in our hearts and prayers.

User avatar
Rudy
Caiman Moderator
Posts: 2704
Joined: Sat May 31, 2008 7:42 pm
Location: Belgium
Contact:

Re: Some PHP help!

Postby Rudy » Sun Sep 21, 2008 1:36 pm

Instead of

Code: Select all

    $body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number: $phone <br>
Comments: $commments <br>
Newsletter: $newsletter <br>
EOD;

why not use a string?

Code: Select all

    $body = "<br><hr><br>Email: "+$email+"<br>Name: "+$name+"<br>Phone Number: "+$phone+"<br>Comments: "+$commments+"<br>Newsletter: "+$newsletter+"<br>";


Return to “TECH DISCUSSION”

Who is online

Users browsing this forum: No registered users and 1 guest