Jump to content

New to php


2words4uready

Recommended Posts

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);
?>

Link to comment
https://forums.phpfreaks.com/topic/119920-new-to-php/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/119920-new-to-php/#findComment-618004
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/119920-new-to-php/#findComment-618259
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.