0

Hi
my php code is not working on my computer, i cannot see any problem with my code either.
when loading my code, it just shows my code printed onto the browser

<?php
$yourname = check_input($_POST);
$email = check_input($_POST);
$likeit = check_input($_POST);
$comments = check_input($_POST);
?>
<html>
<body>
Your name is: <?php echo $yourname; ?><br />
Your e-mail: <?php echo $email; ?><br />
<br />
Do you like this website? <?php echo $likeit; ?><br />
<br />
Comments:<br />
<?php echo $comments; ?>
</body>
</html>

<?php
function check_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>

thats my code

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by weekendrockstar
0

Since you are trying it on your computer do you have a server and PHP installed on your computer? PHP is an interpreted language and needs the PHP on the machine trying to run the code. "<?php" tells the interpreter that it is supposed to run the following code up until "?>". Trying to run PHP files without a server and PHP installed means there's nothing that knows that it is supposed to run your code.

You can either sign up for an account on a free server host that supports PHP (which will be most of them these days) or you can install something like WAMP Server (if you run Windows on a PC). WAMP is free software which runs a server, PHP and MySQL and will allow you to test all of your PHP from your own computer.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.