We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,374 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

php not working

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
1 Hour
Discussion Span
1 Year Ago
Last Updated
2
Views
thehorseman123
Newbie Poster
4 posts since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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.

weekendrockstar
Junior Poster in Training
71 posts since Dec 2010
Reputation Points: 25
Solved Threads: 16
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0581 seconds using 2.66MB