问题
/*loginform.php*/
<html lang="en">
<html>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form method="post" action="login.php">
<fieldset>
<input name="email" type="text">
<input name="password" type="text">
<input type="submit">
</fieldset>
</form>
</body>
</html>
Trying to run the above html code into the below file named "login.php" but it is not pulling any POST data from the form, I have no reason why. I feel like its PhpStorm and XAMPP conflicting, but they are in the right file path ~/xampp/htdocs/folder and the php.exe is from ~/xampp/php/php.exe and it is recognized by PhpStorm.
I realize I should be using isset(), but I'm just trying to figure out what is the real issue.
/*login.php*/
<?php
echo $_POST['email'];
echo $_POST['password'];
?>
Output:
Notice: Undefined index: email in C:\Users\danie\Desktop\xampp\htdocs\gclol\login.php on line 2
Notice: Undefined index: email in C:\Users\danie\Desktop\xampp\htdocs\gclol\login.php on line 3
Any help would be appreciated.
回答1:
Found the issue:
Intellij was going to this by default: http://localhost:63342/gclol/login.php
When it needed to go to my localhost hosted at my MAMP port here: http://localhost/gclol/login.php
Guess, I shouldn't use IDE's in Linux anyways. Back to the good ol' text editors. Lesson learned.
回答2:
URL tells that you are using PhpStorm's (or other IDE's) built in web server.
If you want to use your proper web server (e.g. Apache) then please create and configure Deployment entry and mark it as Default for this project -- if no deployment specified (that's where IDE takes base URL from) PhpStorm will use built-in web server.
That's the way I solved my trouble.
来源:https://stackoverflow.com/questions/36879471/simple-form-php-post-not-working