PHP code is displayed.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Drastic
Forum Newbie
Posts: 2
Joined: Sat Aug 14, 2010 1:12 am

PHP code is displayed.

Post by Drastic »

Hey guys,

So here's a simple HTML form code:

Code: Select all

<html>
<head>
<title>Contact Us</title>
</head>
<body>
<form action="C:\Websites\step2.php" method="post">
Name<br><input type="text" name="username" /><br>
Email<br><input type="text" name="email" /><br>
Inquiry<br><textarea row="7" cols="70" name="inquiry"></textarea><br>
<input type="submit" value="Sumbit" />
</form>
</body>
</html>
And then I create step2.php:

Code: Select all

<?php

$name = $_POST['username'];
$email = $_POST['email'];
$text = $_POST['inquiry'];

echo $name . '<br>' . $email;

?>
Once the user submits their inquiry, the web browser of course goes to step2.php, however the code is displayed, not what the code should display.

How to fix this?

Best regards,
Chase!
raj86
Forum Commoner
Posts: 25
Joined: Tue Sep 29, 2009 12:28 am

Re: PHP code is displayed.

Post by raj86 »

on your (1st page)index page make some changes
remove c:/
use it like this

Code: Select all

[color=#FF0000]<form action="step2.php" method="post">[/color]
than bottom of your 1st page place the following code

Code: Select all

<?php
if (isset($_POST['submit'])) 
{
header ('Location: /your_folder_name_in_www_dir/step2.php');
}
?>
hope this will help you
Drastic
Forum Newbie
Posts: 2
Joined: Sat Aug 14, 2010 1:12 am

Re: PHP code is displayed.

Post by Drastic »

Ok I will give it a shot raj86. I'm a newbie when it comes to PHP so I am not too sure what you told me to do, but I will change the code. I did follow a tutorial and the guy's code worked perfectly! Weird.
User avatar
arrielmabale
Forum Newbie
Posts: 15
Joined: Fri Aug 13, 2010 3:57 pm
Location: Dubai

Re: PHP code is displayed.

Post by arrielmabale »

<form action="C:\Websites\step2.php" method="post">

dont direct them to your c: drive
use the address of your server and not your absolute drive
Post Reply