Hello have a question am making a free email sign up page it works fine but I need to connect to a db and dont know how to call it in the form heres what I have so far.
config.php stored under >public_html
[code]
<?php $dbhost = "localhost"; $dbuname = "domain_emails"; $dbpass = "******"; $dbname = "domain_emails"; $prefix = "email"; $user_prefix = "email"; $dbtype = "MySQL"; ?>[/code]mail.php
[code]
<? include("../config.php"); include("header2.php"); if ($submit){ //**************************** // Connect and select a database // Check for SQL Injection $var = mysql_escape_string($_POST[request_email]); // Run Query $rs = mysql_query("SELECT count(ueid) from `email_accounts` WHERE(ueid=`$var`)"); // Num of Rows $num = mysql_num_rows($sql); if($num>0) { print "Email address already exists"; } // Setup the Auth String $pass = base64_encode($authstr); //Setup an array of all the POST data $formdata = array ( "email" => $email, "domain" => $host, "password" => $password, "quota" => $quota); //build the post string foreach($formdata AS $key => $val){ $poststring .= urlencode($key) . "=" . urlencode($val) . "&"; } // strip off trailing ampersand $poststring = substr($poststring, 0, -1); $fp = fsockopen($host, $port, $errno, $errstr, $timeout = 30); if(!$fp){ //error tell us echo "$errstr ($errno)n"; }else{ //send the server request fputs($fp, "POST $path HTTP/1.1rn"); fputs($fp, "Host: $hostrn"); fputs($fp, "Authorization: Basic $pass rn"); fputs($fp, "Content-type: application/x-www-form-urlencodedrn"); fputs($fp, "Content-length: ".strlen($poststring)."rn"); fputs($fp, "Connection: closernrn"); fputs($fp, $poststring . "rnrn"); //close fp - we are done with it fclose($fp); } echo "Your Email Account Was CreatedTo Access Please Use Outlook
Incoming POP3: mail.$domain
Outgoing SMTP: mail.$domain
Your new email address is: $email@$domain
Password: $password"; }else{ ?>
Free E-Mail Account Sign-Up
Username: @ domain.net domain.comPassword:
<br><br><br><br>
<center>
[ Go Back ]
<? } include("footer.php"); ?>[/code]MySQL DB domain_emails
CREATE TABLE `email_accounts` (
`ueid` bigint(22) unsigned NOT NULL auto_increment,
PRIMARY KEY (`ueid`)
) TYPE=MyISAM AUTO_INCREMENT=1 ;
How can I get it to call the batabase to find out if the email is taken and if its available insert it as now taken when registered?
have tried many combinations but dont seem to work =/
Thanks for your help!