Jump to content

PHP input type=text HELP


Lola777

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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