I want the data to be posted into the datahouse.php which will now submit the data to the server and redirect to Index page without showing the datahouse.php file on page..
register.html
<form method="POST" action="DataHouse.php">
<input type="text" name="username" value="tempapilogin" /><br>
<input type="password" name="password" value="aF4YMjuQ" /><br>
<input type="text" required name="name" placeholder="Full Name" /><br>
<input type="email" required name="email" placeholder="EMail Address" /><br>
Gender:
<fieldset data-role="controlgroup" data-mini="true" >
<input type="radio" name="gender" id="radio-mini-1" value="MALE" />
<label for="radio-mini-1">MALE</label>
<input type="radio" name="gender" id="radio-mini-2" value="FEMALE" />
<label for="radio-mini-2">FEMALE</label>
</fieldset>
Birthday: <input type="date" required name="birth_date" placeholder="dd/mm/yyyy" />
Phone Number: <input placeholder="02xxxxxxxx" type="tel" name="phone_number" />
Facebook ID: <input type="email" name="facebookid" />
<table>
<tr>
<td><input type="submit" name="submit" value="Submit"/></td>
</tr>
</table>
</form>
Below is the php file to post the data to the server and will then have to redirect to the index.html page.
datahouse.php
<?php
//Index.html page to redirect to-->
header("Location: c:\Users\Selorm\Desktop\Maxwell-Internship @ Nandimobile\connect\Index.html");
//create cURL connection
$curl_connection = curl_init();
//create array of data to be posted
array{$post_items[] = 'Username='.strip_tags($_POST['username']);
$post_items[] = 'Password='.strip_tags($_POST['password']);
$post_items[] = 'Email='.strip_tags($_POST['email']);
$post_items[] = 'Gender='.strip_tags($_POST['gender']);
$post_items[] = 'Birthday='.strip_tags($_POST['birth_date']);
$post_items[] = 'Phone Number='.strip_tags($_POST['phone_number']);
$post_items[] = 'Facebook ID='.strip_tags($_POST['facebookid']);}
$username = $_POST['username'];
$password = $_POST['password'];
$name = $_POST['name'];
$email = $_POST['email'];
$gender = $_POST['gender'];
$birth_date = $_POST['birth_date'];
$phone_number = $_POST['phone_number'];
$facebookid = $_POST['facebookid'];
//traverse array and prepare data for posting (key1=value1)
foreach ( $_POST as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//set options and set data to be posted
curl_setopt_array($curl_connection, array(
CURLOPT_CONNECTTIMEOUT => 30,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_AUTOREFERER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_POSTFIELDS => array(
username => 'username',
password => 'password',
name => 'name',
email => 'email',
gender => 'gender',
birth_date => 'birth_date',
phone_number => 'phone_number',
facebookid => 'facebookid' )
));
//perform our request
$result = curl_exec($curl_connection);
$result = json_decode($json);
foreach ($result as $key => $value)
{
echo $key. ':' ;
}
print_r(curl_getinfo($curl_connection));
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' .
curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
exit;
?>