I have a registration system for my “free email” site which does a few functions like inserting info into the database, then it makes an http request to my cpanel which then creates the email account, if all goes well it’s supposed to return with a success page but all it’s doing is returning an error message like this:
Warning: fgets() [function.fgets]: SSL: fatal protocol error in /home/site/public_html/directory/reguser.php on line 88
but if the registration info is sent and the user is already taken I get this error message:
[code]Warning: fgets() [function.fgets]: SSL: fatal protocol error in /home/site/public_html/directory/reguser.php on line 88
Warning: Cannot modify header information - headers already sent by (output started at /home/site/public_html/directory/reguser.php:88) in /home/site/public_html/directory/reguser.php on line 148[/code]
Below is the code for my processor page:
[code]<?php
function check_email_address($email) {
// First, we check that there’s one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&’*+/=?^_{|}~-][A-Za-z0-9!#$%&'*+/=?^_
{|}~.-]{0,63})|("[^(|")]{0,62}"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^[?[0-9.]+]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}
// Check for Available Email Address
$requser = $_GET[‘username’];
if ( $requser == “” ) {
$ermsg = “You must enter a username.”;
}
include (“includes/db.inc.php”);
$dbh=mysql_connect ("$dbhost", “$dbusername”, “$dbpassword”) or die ('I cannot connect to the database because: ’ . mysql_error());
mysql_select_db ("$dbdatabase");
$result = mysql_query(“SELECT id FROM useraccounts WHERE username=’$requser’”)
or die(mysql_error());
$row = mysql_fetch_array( $result );
$id = $row[‘id’];
if ( $id != “” ) {
//echo “Username already taken”;
$ermsg = “Username is already taken.”;
}
//Check for no blank fields
$reqpass = $_GET[‘password1’];
$regfname = $_GET[‘Fname’];
$reglname = $_GET[‘Lname’];
$reqsecquest = $_GET[‘securityquestion’];
$reqsecansw = $_GET[‘securityanswer’];
$reqaltemail = $_GET[‘altemail’];
if ( $reqpass == “” OR $regfname == “” OR $reglname == “” OR $reqsecquest == “” OR $reqsecansw == “” OR $reqaltemail == “” ) {
$ermsg = “All fields of the form must be completed.”;
}
//Validate Alt Email
if (check_email_address($reqaltemail)) {
//$ermsg = “”;
} else {
$ermsg = “Invalid alternate email address.”;
}
if ( $ermsg == “” ) {
// Get Cpanel connection details
$result = mysql_query(“SELECT username, password, ip, port FROM cpanel”)
or die(mysql_error());
$row = mysql_fetch_array( $result );
$cpusername = $row[‘username’];
$cppassword = $row[‘password’];
$cpip = $row[‘ip’];
$cpport = $row[‘port’];
$cpurl = “https://$cpusername:$cppassword@$cpip:$cpport/frontend/$cpskin/mail/doaddpop.html?email=$requser&domain=$domain&password=$reqpass"a=$quota”;
$ok = TRUE;
$file = fopen ("$cpurl", “r”);
if (!$file) {
$ok = FALSE;
$target = “error.php”;
}
while (!feof ($file)) {
$line = fgets ($file, 1024);
if (ereg (“already exists!”, $line, $out)) {
$ok = FALSE;
$target = “error.php”;
}
}
fclose($file);
if ($ok) {
$target = “done.php”;
$form_fields=array_keys($HTTP_POST_VARS);
$temp=“n”;
while($field=array_pop($form_fields)){
$temp.=" $field : = $HTTP_POST_VARS[$field] n";
}
return $line;
//mail($HTTP_POST_VARS[‘to’],“Free Email”,$temp);
//Write to DB
$altemail = $_GET[‘altemail’];
$fname = $_GET[‘Fname’];
$lname = $_GET[‘Lname’];
$securityquestion = $_GET[‘securityquestion’];
$securityanswer = $_GET[‘securityanswer’];
$domainip = GetHostByName($REMOTE_ADDR);
$date = time();
$timestamp = date(“F j, Y, g:i a”,$date);
include (“includes/db.inc.php”);
$dbh=mysql_connect ("$dbhost", “$dbusername”, “$dbpassword”) or die (‘I cannot connect to the database because: ’ . mysql_error());
mysql_select_db ("$dbdatabase");
mysql_query("INSERT INTO useraccounts (username, password, activated, altemail, fname, lname, securityquestion, securityanswer, ip, timestamp, quota) VALUES(’$requser’, ‘$reqpass’, ‘1’, ‘$altemail’, ‘$fname’, ‘$lname’, ‘$securityquestion’, ‘$securityanswer’, ‘$domainip’, ‘$timestamp’, ‘$quota’ ) ") or die(mysql_error());
//Mail to user
$to = "<$altemail>n";
mail($altemail, $subject,
‘Hi ‘.$fname.$messageprt1.$requser.’@’.$domain.$messageprt2.$reqpass.$messageprt3.’’,
“To: $to” .
“From: $fromn” .
“MIME-Version: 1.0n” .
“Content-type: text/html; charset=iso-8859-1”);
// Mail to Admin
//Mail to admin new account notification
$to = “<$adminnotifyaddy>n”;
mail($adminnotifyaddy, ‘New ‘.$domain.’ Email Account Created’,
'New email account created for '.$domain.‘
Email Address: ‘.$requser.’@’.$domain.'
Password: '.$reqpass.'
Quota: ‘.$quota.’ MB
First Name: '.$fname.'
Last Name: '.$lname.'
Security Question: '.$securityquestion.'
Security Answer: '.$securityanswer.'
Alternate Email: '.$altemail.‘
Created :’.$timestamp.‘
IP: ‘.$domainip.’
’,
“To: $to” .
“From: $fromn” .
“MIME-Version: 1.0n” .
“Content-type: text/html; charset=iso-8859-1”);
/********************************************/
}
$target = $target."?newemail=$requser&pass=$reqpass&name=$fname";
header(“location:$target”);
} else {
$target = “error.php?ermsg=$ermsg”;
header(“location:$target”);
}
?>[/code]
If anyone can help me out with this it would be great