Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/307419-php-input-typetext-help/
Share on other sites

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

 

<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 by Lola777

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>

 

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>

 

  • Like 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.