2

dear all, I need to send parameters to a URL without using form in php and get value from that page.We can easily send parameters using form like this:

<html>
    <form action="http://..../abc.php" method="get">
    <input name="id" type="text" />
    <input name="name" type="text"/>
    <input  type="submit" value="press" />
    </form>
</html>

But i already have value like this

     <?php 
       $id="123";
       $name="blahblah";
      ?>

Now i need to send values to http://..../abc.php without using form.when the 2 value send to abc.php link then it's show a value OK.Now i have to collect the "OK" msg from abc.php and print on my current page. i need to auto execute the code.when user enter into the page those value automatically send to a the url.So i can't use form or href. because form and href need extra one click.

Is their any kind heart who can help me to solve this issue?

1
  • 1
    You've been suggested almost all possibilities (clickable link, load page from server, HTTP redirect, AJAX...). You should clarify your exact needs and why none of the solutions are suitable. Commented Nov 30, 2010 at 11:02

3 Answers 3

8

You can pass values via GET using a hyperlink:

<a href='abc.php?id=123&name=blahblah' />

print_r($_GET) would then give you the values, or you can use $_GET['id'] etc in abc.php

Other approaches, depending on your needs, include using AJAX to POST/GET the request asynchronously, or using include/require to pull in abc.php if it only includes specific functioanlity.eg:

   $id="123";
   $name="blahblah";
   require('abc.php');
Sign up to request clarification or add additional context in comments.

2 Comments

Href is not suitable.because i need to send it directly when the code execute.thx any other solution?
@JanHančič You haven't given an answer.
2

You can do:

$id="123";
$name="blahblah";
echo "<a href = 'http://foo.com/abc.php?id=$id&name=$name'> link </a>";

Comments

2
<?php

$base = 'http://example.com/abc.php';
$id="123";
$name="blahblah";

$data = array(
    'id' => $id,
    'name' => $name,
);

$url = $base . '?' . http_build_query($data);

header("Location: $url");
exit;

2 Comments

Your solution is correct but when i send two value to abc.php then it show OK.Now i need to print OK message to my current page.That's why i can't redirect my page.
@riad, not with the information currently available, I'm afraid. Are you sure that none of the solutions provided solve your problem?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.