makeing a page issue

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


<?php $dbhost = "localhost"; $dbuname = "domain_emails"; $dbpass = "******"; $dbname = "domain_emails"; $prefix = "email"; $user_prefix = "email"; $dbtype = "MySQL"; ?>[/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 Created

   To 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:  @


[ 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!

Simply do a query looking for the specific email address ie. SELECT email from blah where email = '$_POST[‘email’];

Then use [phpref]mysql_num_rows[/phpref]

if the values returned are greater then 0 then the email address already exists.
Look at these functions as well…

If you wrote that code above you should have no problem with this part.

“mysql_connect()” is the function you’re looking for. it takes three arguments so far as i know, which are the name of the server (if you’re running the script and it’s on the same server as the mysql database, this will be “localhost”), a username, and a password. all three must be strings, unless you use a variable that contains a string version of each. i highly recommend the variable thing for the username and password.

Sponsor our Newsletter | Privacy Policy | Terms of Service