Lola777 Posted June 29, 2018 Share Posted June 29, 2018 Hello , (( SORY MY ENGLISH IS BAD )) could you help me solve my problem? here is the line of code: <input type=text name=host > I want to recover what a user typed in a text on the page but I would like to add a add to this text add Basically the person typing "user" I would like to add a number by default "999" after what he type: so I get back directly -----------> user999 the code to modify " <input type=text name=host " THE CODE THAT LACKS 999 " > I tested with: <input type=text name=host value="1"> but when I get the text I have an answer with "user & 999" and the "&" me break problem I would like to make it disappear! Thank you Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/ Share on other sites More sharing options...
Barand Posted June 29, 2018 Share Posted June 29, 2018 The PHP concatenation operator is "." $new_host = $_GET['host'] . '999'; Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559163 Share on other sites More sharing options...
Lola777 Posted June 29, 2018 Author Share Posted June 29, 2018 here is my complete code. I would like to retrieve the info to ping it from an ip <form action="/2/test.php" method=GET> DISCORD RESOLVER: OFF <br><input type=text name=host ><br> <input type="hidden" name="count" value="1" > <input type="hidden" name="submit" value="Ping!" > <br> <input type=submit value=RESOLVER></form> I have as a result http://MYDOMAIN.tk/test.php?host=TEXTHOST&count=1&submit=Ping%21 I would like to add after "TEXTHOST" 999. I would like this result : http://MYDOMAIN.tk/test.php?host=TEXTHOST999&count=1&submit=Ping%21 Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559164 Share on other sites More sharing options...
Barand Posted June 29, 2018 Share Posted June 29, 2018 3 minutes ago, Lola777 said: I have as a result http://MYDOMAIN.tk/test.php?host=TEXTHOST&count=1&submit=Ping%21 What is your code that gives that result? Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559165 Share on other sites More sharing options...
Lola777 Posted June 29, 2018 Author Share Posted June 29, 2018 (edited) <form action="http://MYDOMAINE/test.php" method=GET> PING <br><input type=text name=host ><br> <input type="hidden" name="count" value="1" > <input type="hidden" name="submit" value="Ping!" > <br> <input type=submit value=PING></form> Edited June 29, 2018 by Lola777 Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559166 Share on other sites More sharing options...
Barand Posted June 29, 2018 Share Posted June 29, 2018 You won't be able to do that with PHP. It will need to be done client-side before the form is submitted. You can only use PHP after it has been submitted to the server. You will need to use javascript. Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559167 Share on other sites More sharing options...
Lola777 Posted June 29, 2018 Author Share Posted June 29, 2018 would you have a code that could do that? I do not know anything about java Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559168 Share on other sites More sharing options...
Barand Posted June 29, 2018 Share Posted June 29, 2018 You could try this (not tested) <html> <head> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <script type="text/javascript"> $().ready( function() { $("#form1").submit( function() { var v = $("#host").val() $("#host").val(v+"999"); return true; }) }) </script> </head> <body> <form id="form1" action="http://MYDOMAINE/test.php" method=GET> PING <br><input type="text" name="host" id="host"><br> <input type="hidden" name="count" value="1" > <input type="hidden" name="submit" value="Ping!" > <br><input type="submit" value="PING"> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559169 Share on other sites More sharing options...
Lola777 Posted June 29, 2018 Author Share Posted June 29, 2018 hum. the result looks promising to me! . I will readjust the code. but I think it will work. thank you for giving me your time to solve my problem. I install this on my site. I inform you of the result Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559171 Share on other sites More sharing options...
Lola777 Posted June 29, 2018 Author Share Posted June 29, 2018 perfect ! thank you very much for your help ! Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559173 Share on other sites More sharing options...
Barand Posted June 30, 2018 Share Posted June 30, 2018 Afterthought: If you want a solution without javascript (php only) submit the form to itself, amend the host value, redirect to required page <?php if ( isset($_GET['host']) && trim($_GET['host']) != '' ) { $query = []; parse_str($_SERVER['QUERY_STRING'], $query); // convert querystring to an array $query['host'] .= '999'; // append '999' to host element $url = "http://MYDOMAINE/test.php?" . http_build_query($query); // build revised url with querystring header("Location: $url"); // redirect to original action page with new value exit(); } ?> <html> <head> <title>Sample</title> </head> <body> <form id="form1" method=GET> <!-- no 'action' attribute so form calls itself --> PING <br><input type="text" name="host" id="host"><br> <input type="hidden" name="count" value="1" > <input type="hidden" name="submit" value="Ping!" > <br><input type="submit" value="PING"> </form> </body> </html> 1 Quote Link to comment https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/#findComment-1559177 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.