2words4uready Posted August 16, 2008 Share Posted August 16, 2008 I just started php today and was wondering why this doesn't work? index.php <form action="next.php" method="post"> Enter your name: <input type="text" name="name" /> Enter your age: <input type="text" name="age" /> <input type="submit" /> </form> next.php <?php $file = fopen(test.txt, "a+"); fwrite($file,$_Post ["name"]; fwrite($file,$_Post ["age"]; fclose(test.txt); ?> Quote Link to comment https://forums.phpfreaks.com/topic/119920-new-to-php/ Share on other sites More sharing options...
natbob Posted August 16, 2008 Share Posted August 16, 2008 The code for the form is fine but on next.php you forgot to close your function calls and you need to quote the filename as so. <?php $file = fopen("test.txt", "a+"); fwrite($file, $_POST["name"]); fwrite($file, $_POST["age"]); fclose("test.txt"); ?> I hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/119920-new-to-php/#findComment-617773 Share on other sites More sharing options...
2words4uready Posted August 16, 2008 Author Share Posted August 16, 2008 Thanks. Just some simple noobish code bugs. Quote Link to comment https://forums.phpfreaks.com/topic/119920-new-to-php/#findComment-617776 Share on other sites More sharing options...
Barand Posted August 16, 2008 Share Posted August 16, 2008 Also, all variable names in PHP are case-sensitive so $_Post is not the same as $_POST. You need the latter as natbob has used. Quote Link to comment https://forums.phpfreaks.com/topic/119920-new-to-php/#findComment-617905 Share on other sites More sharing options...
PFMaBiSmAd Posted August 16, 2008 Share Posted August 16, 2008 Also, the fclose() statement would need to be - fclose($file); From the php manual - Description bool fclose ( resource $handle ) When learning php, developing php code, or debugging php code, set error_reporting to E_ALL and display_errors to on in your php.ini (stop and start your web server to get any changes made to php.ini to take effect) to get php to help you. Each of the problems pointed out would have generated an error message of some kind. Quote Link to comment https://forums.phpfreaks.com/topic/119920-new-to-php/#findComment-618004 Share on other sites More sharing options...
2words4uready Posted August 17, 2008 Author Share Posted August 17, 2008 How bout this code? Index.php <html> <head> <title><?PHP?></title> </head> <body> <form action="index.php" method=POST> Username: <input type=text name=user><br> Password: <input type=password name=pass> <input type=submit value="Login"> </form> <?php $user=$_POST["user"]; $pass=$_POST["pass"]; $user1="user" $pass1="pass" If (($user==$user1)&&($pass==$pass1)){ echo "Access Granted" } else { echo "Access Denied" ) ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/119920-new-to-php/#findComment-618259 Share on other sites More sharing options...
Aeglos Posted August 17, 2008 Share Posted August 17, 2008 You are missing mutiple semicolons at the end your statements. Quote Link to comment https://forums.phpfreaks.com/topic/119920-new-to-php/#findComment-618287 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.