thehubclick Posted December 29, 2019 Share Posted December 29, 2019 (edited) <INPUT TYPE = "Text" VALUE ="0" ID = "username2" NAME = "username2"> <?php $value1 = $_POST['username2']; $nine=$value1; $codx =$characters[$nine]->name; ?> Im tring to get '0' in username2 inputbox readit in php $nine $codx =$characters[$nine]->name; as you can see in my <?php code above I cant get the 0 from this inputbox It only works like this <?php $nine='0' $codx =$characters[$nine]->name; ?> What i need is to get the users input. from a textbox on my page called username2 they would enter between 0 and 8 as you can see its set to 0 on my textbox, the 0 - 8 is the character location $characters[$nine] the $nine will hold the number between 0 - 8 My php code i cant read my texbox input. How do I read the user input into my my textbox post pulls the input $nine = $_POST['username2']; $codx =$characters[$nine]->name; i noticed it wouldn't work it only works this way $nine='0'; $codx =$characters[$nine]->name; Let me know how to read in user input from my username2 textbox. Thanks in advance sorry to repeat i needed to explain so you can see my error. Edited December 30, 2019 by Psycho none Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/ Share on other sites More sharing options...
gw1500se Posted December 29, 2019 Share Posted December 29, 2019 First please use the code icon (<>) for your PHP and select PHP or HTML for that code. It makes your code easier to read. Did you echo $value1 to make sure it is what you expect? As a guess, since you don't show that code, I suspect the problem is with the array $characters. Did you var_dump that to make sure it is correct? Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572960 Share on other sites More sharing options...
Barand Posted December 29, 2019 Share Posted December 29, 2019 What is the form method of the form that contains your username2 input? Is it POST? Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572962 Share on other sites More sharing options...
thehubclick Posted December 31, 2019 Author Share Posted December 31, 2019 (edited) Sorry. For delay I m using POST.. To get 0 - 8 im using input username2 lets say i put 0 in username2 input when I click post i need to grab that 0 and pass it to my $charactors[$nine]->name Its not reading my string $nine from my input box username2. Like i wrote earlier ^^^ it will only work this (< Then $nine='0'; $codx =$characters[$nine]->name; When i write in javascript working with the input box i can read it into a string but not in Php programming. I m still learning php im sure this isnt that hard to do. Hope any experts in php here can see my issue. Hope my code displays right. About making code easy to read is it < code > or (< code. >) ill try both my bad if this dont work. (< <form action="" method="post"> <input disabled="disabled" style="background-color:white; color: white" type="text" name="subject" id="subject" size="1" style="display:none" value="1"> <hr> Password: <br><input style="background-color:black; color: white" type="password" name="text_one" value="0923532"> <button type="submit" name="ok">OK</button> dec19/ <INPUT TYPE = "Text" VALUE ="" ID = "username2" NAME = "username2"> </form> Edited December 31, 2019 by thehubclick Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572988 Share on other sites More sharing options...
thehubclick Posted December 31, 2019 Author Share Posted December 31, 2019 I cant get my code to display ^^^ up there (<>) my bad Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572989 Share on other sites More sharing options...
Barand Posted December 31, 2019 Share Posted December 31, 2019 It's [ code ]…[ /code ] (but without the spaces) or just use the <> button on the toolbar Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572990 Share on other sites More sharing options...
thehubclick Posted December 31, 2019 Author Share Posted December 31, 2019 On 12/29/2019 at 10:22 AM, gw1500se said: First please use the code icon (<>) for your PHP and select PHP or HTML for that code. It makes your code easier to read. Did you echo $value1 to make sure it is what you expect? As a guess, since you don't show that code, I suspect the problem is with the array $characters. Did you var_dump that to make sure it is correct? I cant get code to display right. In (<>). I need help Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572991 Share on other sites More sharing options...
thehubclick Posted December 31, 2019 Author Share Posted December 31, 2019 1 minute ago, Barand said: It's [ code ]…[ /code ] (but without the spaces) or just use the <> button on the toolbar Thank you Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572992 Share on other sites More sharing options...
thehubclick Posted December 31, 2019 Author Share Posted December 31, 2019 (edited) 8 minutes ago, thehubclick said: Thank you 8 minutes ago, thehubclick said: Thank you Thanks Barand that fixed my code displaying code inside my code correctly i will make sure to use it when posting my php or html code here. Thanks again Edited December 31, 2019 by thehubclick Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572994 Share on other sites More sharing options...
thehubclick Posted December 31, 2019 Author Share Posted December 31, 2019 Oh by the way im using my android phone to post and code i dont see the <> button icon . It might be on the desktop and not my android phone. Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572995 Share on other sites More sharing options...
Barand Posted December 31, 2019 Share Posted December 31, 2019 Are you checking if data has actually been POSTed if ($_SERVER['REQUEST_METHOD'] == 'POST') { $nine = $_POST['username2']; $codx = $characters[$nine]->name; } else { echo "NO DATA!"; } Quote Link to comment https://forums.phpfreaks.com/topic/309761-textbox-input/#findComment-1572997 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.