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?

riad
  • 7,144
  • 22
  • 59
  • 70
  • 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. – Álvaro González Nov 30 '10 at 11:02

3 Answers3

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');
SW4
  • 69,876
  • 20
  • 132
  • 137
2

You can do:

$id="123";
$name="blahblah";
echo "<a href = 'http://foo.com/abc.php?id=$id&name=$name'> link </a>";
codaddict
  • 445,704
  • 82
  • 492
  • 529
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;
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • 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 Nov 30 '10 at 10:57
  • @riad, not with the information currently available, I'm afraid. Are you sure that none of the solutions provided solve your problem? – Álvaro González Nov 30 '10 at 11:48