PHPstorm $_POST not working

Hi,

  I just started using PHPStorm with WAMP and everything was working fine until I tried to create a simple form. I know about isset, but when I set that, it was never defined. I am very confused. The code is below:

<?php
/**
* Created by PhpStorm.
* User: njden_000
* Date: 2/11/2015
* Time: 12:27 PM
*/
    $servername = "localhost";
    $username = "root";
    $password = "";
    $fileSaved = False;
    $conn = mysqli_connect($servername, $username, $password);
    if(!$conn){
        die("Trouble connecting to server");
    }
    else {
        echo "success";
        $strAttr  = 0;
        if(isset($_POST['str'])){ $strAttr = $_POST['str']; }
       # $conAttr = $_POST['con'];
       # $wisAttr = $_POST['wis'];
       # $intelAttr = $_POST['int'];
       # $chaAttr = $_POST['cha'];
       # $agiAttr = $_POST['agi'];
        echo $strAttr;
        $fileSaved = True;
    }
?>


html


<p>It's time to create your character! Name your player and click roll to see what stats they have.</p><br />
<textarea id="nameAttr" rows="1" cols="15" maxlength="15" style="overflow:hidden; resize:none"></textarea><br />
<form action="saveConfig.php" method="post">
<p >Strength: </p><p id="strAttr" name="str" >0</p><br />
<p>Constitution: </p><p id="conAttr" name="con">0</p><br />
<p>Wisdom: </p> <p id="wisAttr" name="wis">0</p><br />
<p>Intelligence: </p><p id="intAttr" name="intel">0</p><br />
<p>Charisma: </p><p id="chaAttr" name="cha">0</p><br />
<p>Agility: </p><p id="agiAttr" name="agi">0</p><br />

<button>Continue</button>
</form>
<button onclick="rollAttr()">Roll</button><br /> <!-- The javascript functions work fine -->
0
Avatar
Permanently deleted user

Hard to tell without the javascript here to see how you are submitting the form.

Do you have xdebug enabled on your Wampserver? If so, which Superglobals are showing up?

0
Avatar
Permanently deleted user

There isn't any javascript that sends the info, the form action is supposed to do that with the method and action attributes after I press continue button. It loads the php perfectly, I echoed a "hello world" and that worked, but it doesn't send the str information. Anyone know why? What's xdebug? I don't have that enabled. I"m a beginner with all this stuff.

0
Avatar
Permanently deleted user

If there's nothing submitting from the javascript, I don't think your form is submitting, which is why you're not seeing any values.

Try instead

<button type="submit" />

if that doesn't work, try a simple input submit, but I think either should do the trick.

<input type="submit" />

See if this give you better luck.

----

XDebug is a debugger that gives you a really good look at what's happening when you do a submit.

https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html <-- here's how to set it up. It's really, really useful.

0
Avatar
Permanently deleted user

I figured it out. I used <p> instead of inputss; oops.


0

请先登录再写评论。