Jump to content
Lola777

PHP input type=text HELP

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

Share this post


Link to post
Share on other sites

The PHP concatenation operator is "."

$new_host = $_GET['host'] . '999';

 

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Posted (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 by Lola777

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

would you have a code that could do that?
I do not know anything about java

Share this post


Link to post
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>

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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>

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

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.