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 script not running

Hi community,

I recently started learning html and I tried to make a short feedback form. That should send the data over to a php file and that should append it to a txt file. However, every time I try to submit my form data, I keep just seeing the PHP code. I have installed php.

<?php
$name = $_post['username'];
$email = $_post['pass'];
$fp = fopen(”formdata.txt”, “a”);
$savestring = $name . “,” . $email . “n”;
fwrite($fp, $savestring);
fclose($fp);
echo “<h1>You data has been saved in a text file!</h1>”;
?>
<html><body>
<form name="userpassform" id="user_pass_form" action="formsaver.php" method="post">
Username<input type="text" name="username"/> <br />
Password<input type="password" name="pass"/> <br />
<input type="submit" value="Submit"/>
<input type="reset">
</form>
</body>
</html>

I'm running everything locally from my computer. Help is appreciated =)

Kind regards

4
Contributors
3
Replies
11 Hours
Discussion Span
1 Year Ago
Last Updated
4
Views
albo1125
Newbie Poster
3 posts since Jul 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Check that the files you are using are being ran through localhost.

Make sure all your services are started.

iamthwee
Posting Genius
6,254 posts since Aug 2005
Reputation Points: 1,567
Solved Threads: 476
Skill Endorsements: 34

If you're running Apache, and PHP, have you installed and configured mod_php5? This is what essentially links the two and tells the web server to parse the PHP code, rather than just return it.

blocblue
Practically a Posting Shark
837 posts since Jan 2008
Reputation Points: 272
Solved Threads: 161
Skill Endorsements: 12

You don't need to login to the database to run your script. However, your Apache server must be on.

SQLpower
Junior Poster in Training
82 posts since May 2011
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

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

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0719 seconds using 2.83MB