SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $_Request and returning variable

    Hi all i have a variable i want to be included in a form already and when page loads it send the information to a remote server this is what i done so far,

    PHP Code:
    $dbhost="localhost";
    $dbuser="dbuser";
    $dbpassword="pass";
    $dbname="dbname";
    ?>
    <form method="POST" action="">
    <input type="hidden" name="dbhost" value="<?php $dbhost;?>">
    <input type="hidden" name="dbuser" value="<?php $dbuser;?>">
    <input type="hidden" name="dbpassword" value="<?php $dbpassword;?>">
    <input type="hidden" name="dbname" value="<?php $dbname;?>">
    </form>
    <?
    $dbhost
    =$_POST['dbhost'];
    $dbuser=$_POST['dbuser'];
    $dbpassword=$_POST['dbpassword'];
    $dbname=$_POST['dbname'];
    echo 
    "Database Host".$dbhost."";
    echo 
    "Database username".$dbuser."";
    echo 
    "Database Pass".$dbpassword."";
    echo 
    "Database Name".$dbname."";
    if(
    $dbhost || $dbuser || $dbpassword || $dbname)
    {
    echo 
    "WATEVER":
    }
    else
    {
    echo 
    "You havent filled out the information above.";
    }
    The other end on reciving i have

    PHP Code:
    $dbhost=$_REQUEST['dbhost'];
    $dbuser=$_REQUEST['$dbuser'];
    $dbpassword=$_REQUEST['dbpassword'];
    $dbname=$_REQUEST['dbname'];
    //
    $con=mysqli_connect($dbhost,$dbuser,$dbpassword,$dbname);
    if(!
    $con)
    {
        echo 
    "Unable to connect to Database or Clan Scripts not Installed<br/><br/>";
        exit;
    }
    else
    {
        
        echo 
    "Database Host".$dbhost."";
        echo 
    "Database username".$dbuser."";
        echo 
    "Database Pass".$dbpassword."";
        echo 
    "Database Name".$dbname."";
        

    What i am doing wrong How can i fix this??

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    First of all, you'll have to put something into the action parameter of your form, and you'll have to add a button for the user to click on to send the form.

    Second, the action will send the form data to the script you indicate, so or the first or the second of your two scripts.

    Third, all the php code in your first script after the form should be in the second form, or on top of the first (if your first script receives these values through POST).

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can i have it without the user clicking a buttton?

    Since the Second Script is on a remote server

  4. #4
    Theoretical Physics Student bronze trophy Jake Arkinstall's Avatar
    Join Date
    May 2006
    Location
    Lancaster University, UK
    Posts
    7,062
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    you can do it via Curl's form sending methods.
    Jake Arkinstall
    "Sometimes you don't need to reinvent the wheel;
    Sometimes its enough to make that wheel more rounded"-Molona

  5. #5
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you able to post me to a good tutorial for what i am wanting to do and would i need curl to be installed or is it a language like php or a new php function that people would need if they a remote linking to other servers?

  6. #6
    SitePoint Wizard lorenw's Avatar
    Join Date
    Feb 2005
    Location
    was rainy Oregon now sunny Florida
    Posts
    1,098
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    you can't go wrong with google and php.net.
    google for
    php curl post form


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •