Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8261517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T03:26:08+00:00 2026-06-08T03:26:08+00:00

I am trying to make a validation for a form and if everything goes

  • 0

I am trying to make a validation for a form and if everything goes right it should go to the 2nd page, where it should take the information from the $_POST.

I was told that given the way I am doing it, $_POST would not work and I should try cURL. I tried to make it work, but somehow it does not work. It redirects correctly to the install2.php but its not passing any variables to it. What i am doing wrong?

My code is as follows:

<?php 
//If the person pressed summit check for the information submited. If everything is correct move to the next page.
if (isset($_POST['submit'])) 
{
    // declare Variables
    $username = $_POST['username'];
    $password = $_POST['password'];
    $server = $_POST['server'];
    $message = "The following fields are empty: ";

    //Step 1 : Check if username & server are empty and if they are return the correct error
    if (empty($username) || empty($server) )
    {  
        if (empty($username)) { 
            $message .= "Username";
        }       
        if (empty($password)) {
            $message .= " Password";
        }
        if (empty($server)) {   
            $message .= " Server";
        }           
    }
    else 
    {       
        //Step 2: Attempt to connect to the DB with the information provided. if not sucessful return to correct error to the user.
        @$connection = mysql_connect($server,$username,$password);
        if (!$connection) 
        {
            $message = "Please check your details. the script was unable to connect to the db.";
        }
        else 
        { 
            //Step 3: Since the connection was stablished successfuly with the information provided then send the login details tot he next page
            // NOTE: For porpuses of this script I am only passing 1 variable... to make my life easier
            $ch = curl_init (); 
            curl_setopt ($ch, CURLOPT_URL, 'http://localhost/install2.php');
            curl_setopt ($ch, CURLOPT_POST, TRUE);
            curl_setopt ($ch, CURLOPT_POSTFIELDS, $username);
            curl_setopt ($ch, CURLOPT_RETURNTRANSFER, TRUE);

            $response = curl_exec ($ch);

            curl_close ($responde);
            header ('location: install2.php');
        }
    }
}
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T03:26:11+00:00Added an answer on June 8, 2026 at 3:26 am

    That’s not the way to pass post-fields:

    curl_setopt ($ch, CURLOPT_POSTFIELDS, $username);
    

    you should create a string:

    $data = "username=$username&password=$password";
    

    and pass it:

    curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
    

    Second, better encode the parameters you’re passing using urlencode().

    And last, it DOES pass the parameters when you call:

    $response = curl_exec ($ch);
    

    but, then you don’t read the response and just redirect the user to:

    header ('location: install2.php');
    

    this time it’s a call with no parameters which explains your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use the jQuery Validation plugin to make a multistep form with
I'm trying to make a simple Form Validation so the Form shows errors This
Trying to make a validation on form without <form> tag. Its a structure of
I'm trying to make a form validation method. and I'm facing a couple of
im trying to make a registration form with ajax validation check. validation check is
I am trying to make an edit page where the form fields are populated
Possible Duplicate: MVC3 custom validation: compare two dates I am trying to make a
I have an entry.rb model and I'm trying to make a semi-complicated validation. I
I am trying to create a validation that checks to make sure a domain/url
I am trying to create a Validation in a reusable fashion. Purpose: Make the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.