Page 1 of 1

PHP code is displayed.

Posted: Sat Aug 14, 2010 1:16 am
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!

Re: PHP code is displayed.

Posted: Sat Aug 14, 2010 2:04 am
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

Re: PHP code is displayed.

Posted: Sat Aug 14, 2010 2:12 am
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.

Re: PHP code is displayed.

Posted: Sat Aug 14, 2010 2:54 am
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