Jump to content

masterinex

New Members
  • Content Count

    7
  • Joined

  • Last visited

Community Reputation

0 Neutral

About masterinex

  • Rank
    Newbie
  1. when i run this code , i am getting undefined index for password , phonenumber and nickname. form1.html: <html> <body> <form action="welcome.php" method="post"> E-mail: <input type="text" name="email"><br> Password: <input type="text" name="password"><br> Nickname: <input type="text" name="nickname"><br> Phonenumber: <input type="text" name="phonenumber"><br> <input type="submit"> </form> </body> </html> welcome.php: <html> <body> Welcome <?php echo $_POST["name"]; ?><br> Your email address is: <?php echo $_POST["email"]; ?> <?php //Step1 $db = mysqli_connect('localhost','root','','users') or die('Error connecting to MySQL server.'); ?> <html> <head> </head> <body> <h1>PHP connect to MySQL</h1> <?php $email = $_POST['email']; $password = $_POST['password']; $phonenumber = $_POST['phonenumber']; $nickname = $_POST['nickname']; $sql ="INSERT INTO users (email,password,nickname,phonenumber) VALUES ('$email','$password','$nickname' , '$phonenumber' )"; mysqli_query($db,$sql); //Step2 $query = "SELECT * FROM users"; mysqli_query($db, $query) or die('Error querying database.'); //Step3 $result = mysqli_query($db, $query); //$row = mysqli_fetch_array($result); while ($row = mysqli_fetch_array($result)) { echo $row['email'] . ' ' . $row['password'] . ' '. $row['nickname'] . ' '. $row['phonenumber'] .'<br />'; } //Step 4 mysqli_close($db); ?> </body> </html> when i run this code , i am getting undefined index for password , phonenumber and nickname.
  2. whenever i create a new file, when i right click it, and the first time i run it , i get to choose from 2 options, JavaScript debug and php debug. when i choose JavaScript debug , it will open the php file in a browser , and when i choose php debug it will choose to open in the phpstorm console and also allow me to debug the file. why is that i only have these 2 option only for the first time when i run the file , after i have choosen an option , i can't go back and choose the other option ?
  3. for some reason it works when i create a new user and choose host as local , but when i have a user which host is the % it does not work. i am following this tutorial: https://www.youtube.com/watch?v=BSG61edYsYQ
  4. I am using phpmyadmin with xampp. in C:\xampp\phpmyAdmin\config.inc.php I have: /* Authentication type and info */ $cfg['Servers'][$i]['auth_type'] = 'cookie'; $cfg['Servers'][$i]['user'] = 'root'; $cfg['Servers'][$i]['password'] = '123'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['AllowNoPassword'] = false; $cfg['Lang'] = ''; it would not allow me to set a password for user root . i keep getting #1045 - Access denied for user 'root'@'localhost' (using password: YES)
  5. <?php // Start the session session_start(); ?> <!DOCTYPE html> <html> <body> <?php // Set session variables $_SESSION["favcolor"] = "green"; $_SESSION["favanimal"] = "cat"; $_SESSION["favmeal"] = "shep"; echo "Session variables are $_SESSION[\"favmeal\"] " ; ?> </body> </html> what is wrong with this code, how come it wont show favmeal ?
  6. <?php $a = 1; $a = $a + 1; $expiry = new DateTime('+1year') ; setcookie( 'language' , 'EN-GB', $expiry->getTimestamp()); var_dump($_COOKIE); echo "Hello world!"; ?> When i run this in phpstorm , i am getting this output: C:\xampp\htdocs\Sandbox\index.php:11: array (size=1) 'Phpstorm-aa4c01d' => string 'cc5eb5a0-3c37-42ff-8538-e849091f48c8' (length=36) Hello world! how come var_dump does not give me the language and 'EN-GB' as output ?
  7. <?php $bar = 0 ; function foo(&$bar) { $bar++; echo "Before unset: $bar, "; unset($bar); //echo " unset: $bar, "; $bar = 23; echo "after unset : $bar \n"; } function foo2() { //static $bar; $bar++; echo "Before unset: $bar, "; unset($bar); //echo " unset: $bar, "; $bar = 23; echo "after unset : $bar \n"; } foo($bar); foo($bar); foo($bar); ?> when i run the code i am getting : Before unset 1, after unset:23 Before unset 2, after unset 23 Before unset 3, after unset 24 ; should it not be : Before unset 1, after unset:23 Before unset 24, after unset:23 Before unset 24, after unset:23 because after the first time the function foo is called , the value of bar is 23 and when it enters the foo the second time its value will be incremented from 23 +1 which is 24 which yields the line Before unset 24, after unset:23 is my logic correct ?
×
×
  • 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.