PHP. Используйте cURL для отправки информации на другую страницу.

Я пытаюсь сделать валидацию для формы, и если все пойдет правильно, она должна перейти на вторую страницу, где она должна взять информацию из $ _POST.

Мне сказали, что, учитывая то, как я это делаю, $ _POST не работает, и я должен попробовать cURL. Я пытался заставить его работать, но почему-то это не работает. Он перенаправляет корректно на install2.php но не передает ему никаких переменных. Что я делаю неправильно?

Мой код выглядит следующим образом:

 <?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'); } } } ?>