•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 426,905 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,313 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 389 | Replies: 5
![]() |
•
•
Join Date: Jan 2008
Posts: 19
Reputation:
Rep Power: 1
Solved Threads: 0
can some 1 explain to me why this takes over 24+ or even 1 week to send an email to the user with his password to be able to log onto my site. the coding is below.
i need the email to be nearly instant!
<?php
session_start();
include_once"includes/db_connect.php";
if (isset($_SESSION['username'])){
header("Location: /game/play.php");
exit();
}
$referal=$_GET['ref'];
$referal2=$_POST['ref2'];
$scriptcheck=$_POST['scriptcheck'];
$scriptcheck2=$_POST['scrip'];
$sc=rand(111,999);
if(!$referal2){
$referal2=0;
}
if ($_POST['Submit']){
// Define post fields into simple variables
$reg_username = $_POST['reg_username'];
$email = $_POST['email'];
$email1 = $_POST['email1'];
$location=strip_tags($_POST['location']);
$reg_username=trim($reg_username);
$today = gmdate('Y-m-d H:i:s');
$reg_username = stripslashes($reg_username);
$email = stripslashes($email);
$reg_username = strip_tags($reg_username);
$email = strip_tags($email);
if((!$reg_username) || (!$email) || (!$location)){
$message="Please fill in all fields";
}else{
if ($email != $email1){
$message="Emails do not match";
}elseif ($email == $email1){
if($scriptcheck != $scriptcheck2){
print"Script check wrong!";
}else{
if (ereg('[^A-Za-z]', $reg_username)) {
$message="Your username can only contain letters.";
}elseif (!ereg('[^A-Za-z]', $reg_username)) {
if (strlen($reg_username) <= 3 || strlen($reg_username) >= 40){
$message= "Username too big or small.";
}elseif (strlen($reg_username) > 3 || strlen($reg_username) < 40){
$sql_email_check = mysql_query("SELECT email FROM users
WHERE email='$email' AND status='Alive'");
$sql_username_check = mysql_query("SELECT username FROM users
WHERE username='$reg_username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Im sorry but there has been an error please read on..<br />";
if($email_check > 0){
print"Your email address has already been used by another gangster!";
unset($email);
}
if($username_check > 0){
print"Your desired username is already in use!";
unset($reg_username);
}
}else{
$ip = $_SERVER['REMOTE_ADDR'];
$random_password44=rand(1111111,99999999);
$time=time();
mysql_query("INSERT INTO `user_info` ( `id` , `username`)
VALUES (
'', '$reg_username')");
mysql_query("INSERT INTO `users` ( `id` , `username` , `password` , `money` , `regged` , `email` , `location` , `ip` , `r_ip`, `referal`)
VALUES ('', '$reg_username', '$random_password44', '10000', '$time', '$email', '$location', '$ip', '$ip', '$referal2')") or die(mysql_error);
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "Modern Mobsters";
$message = "Thank you for registering at Modern Mobsters,
You can login to the game at www.modern-mobsters.com with the following details:
Username: $reg_username
Password: $random_password44
Please change your password onced you're logged in for your safety.
Thank you very much for registering
http://www.modern-mobsters.com staff.
Note: This is an automated email, please do not reply as you wont get response.";
mail($email, $subject, $message,
"From: Modern Mobsters<mailserver@modern-mobsters.com>");
echo "Your account has been registered! Check your email for your password!";
} }}}}}}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Register</title>
<link href="stylesheets/index.css" rel="stylesheet" type="text/css" />
<script language=JavaScript>
function so(dis)
{
for (i=0;i<dis.elements.length;i++){
if (dis.elements[i].type=='submit')
dis.elements[i].style.visibility='hidden';
}
if(fs==false){
fs=true;
return true;
}else
return false;
}
function goaway()
{
for(i=0;i<document.forms.length;i++)
document.forms[i].onsubmit = function() {return so(this);};
}
</script>
</head>
<body onLoad="goaway();">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="header">Modern Mobsters</td>
</tr>
<tr>
<td height="18" align="center"><div id="sectionLinks">
<a href="index.php">Home</a><a href="register.php">Register</a><a href="lostpass.php">Lost Password</a><a href="/screens.php">Screenshots</a><a href="story.php">Story Line </a></div></td>
</tr>
<tr>
<td height="300" class="main"><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<form action="" method="post" name="form2" id="form2">
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="130" height="40" class="bodytext"> Username: </td>
<td width="57%"><input name="reg_username" type="text" id="reg_username" maxlength="40" /></td>
</tr>
<tr>
<td class="bodytext">E-mail:</td>
<td><input name="email" type="text" id="email" value="" /></td>
</tr>
<tr>
<td class="bodytext">Re-Type E-mail: </td>
<td><input name="email1" type="text" id="email1" value="" /></td>
</tr>
<tr>
<td height="20" class="bodytext">Starting Location </td>
<td><select name="location" class="ddm" id="location" >
<option value="England" selected="selected">England</option>
<option value="China">China</option>
<option value="France">France</option>
<option value="Holland">Holland</option>
<option value="USA">USA</option>
<option value="Germany">Germany</option>
<option value="Canada">Canada</option>
<option value="South Africa">South Africa</option>
</select></td>
</tr>
<tr>
<td height="20" class="bodytext"><p>Script Check: <b><? print"$sc"; ?></b></p>
</td>
<td><input name="scriptcheck" type="text" id="scriptcheck" value="" />
<input type="hidden" value="<? print"$sc"; ?>" name="scrip"></td>
</tr>
<tr>
<td height="20" class="bodytext">Referal (optional) </td>
<td>
<? if(!$referal){ ?>
<input name="ref2" type="text" id="ref2" value="<? print"$referal"; ?>" maxlength="40" />
<? }else{ ?>
<input name="ref2" type="text" id="ref2" value="<? print"$referal"; ?>" maxlength="40" READONLY>
<? } ?> </td>
</tr>
<tr>
<td> </td>
<td> <input name="Submit" type="submit" class="submit" value="Register!" /> </td>
</tr>
</table>
</form> </td>
</tr>
</table>
<center>
</td>
<td> </td>
</tr>
<tr>
<td height="14"></td>
</tr>
</center>
</body>
</html>
i need the email to be nearly instant!
<?php
session_start();
include_once"includes/db_connect.php";
if (isset($_SESSION['username'])){
header("Location: /game/play.php");
exit();
}
$referal=$_GET['ref'];
$referal2=$_POST['ref2'];
$scriptcheck=$_POST['scriptcheck'];
$scriptcheck2=$_POST['scrip'];
$sc=rand(111,999);
if(!$referal2){
$referal2=0;
}
if ($_POST['Submit']){
// Define post fields into simple variables
$reg_username = $_POST['reg_username'];
$email = $_POST['email'];
$email1 = $_POST['email1'];
$location=strip_tags($_POST['location']);
$reg_username=trim($reg_username);
$today = gmdate('Y-m-d H:i:s');
$reg_username = stripslashes($reg_username);
$email = stripslashes($email);
$reg_username = strip_tags($reg_username);
$email = strip_tags($email);
if((!$reg_username) || (!$email) || (!$location)){
$message="Please fill in all fields";
}else{
if ($email != $email1){
$message="Emails do not match";
}elseif ($email == $email1){
if($scriptcheck != $scriptcheck2){
print"Script check wrong!";
}else{
if (ereg('[^A-Za-z]', $reg_username)) {
$message="Your username can only contain letters.";
}elseif (!ereg('[^A-Za-z]', $reg_username)) {
if (strlen($reg_username) <= 3 || strlen($reg_username) >= 40){
$message= "Username too big or small.";
}elseif (strlen($reg_username) > 3 || strlen($reg_username) < 40){
$sql_email_check = mysql_query("SELECT email FROM users
WHERE email='$email' AND status='Alive'");
$sql_username_check = mysql_query("SELECT username FROM users
WHERE username='$reg_username'");
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Im sorry but there has been an error please read on..<br />";
if($email_check > 0){
print"Your email address has already been used by another gangster!";
unset($email);
}
if($username_check > 0){
print"Your desired username is already in use!";
unset($reg_username);
}
}else{
$ip = $_SERVER['REMOTE_ADDR'];
$random_password44=rand(1111111,99999999);
$time=time();
mysql_query("INSERT INTO `user_info` ( `id` , `username`)
VALUES (
'', '$reg_username')");
mysql_query("INSERT INTO `users` ( `id` , `username` , `password` , `money` , `regged` , `email` , `location` , `ip` , `r_ip`, `referal`)
VALUES ('', '$reg_username', '$random_password44', '10000', '$time', '$email', '$location', '$ip', '$ip', '$referal2')") or die(mysql_error);
$userid = mysql_insert_id();
// Let's mail the user!
$subject = "Modern Mobsters";
$message = "Thank you for registering at Modern Mobsters,
You can login to the game at www.modern-mobsters.com with the following details:
Username: $reg_username
Password: $random_password44
Please change your password onced you're logged in for your safety.
Thank you very much for registering
http://www.modern-mobsters.com staff.
Note: This is an automated email, please do not reply as you wont get response.";
mail($email, $subject, $message,
"From: Modern Mobsters<mailserver@modern-mobsters.com>");
echo "Your account has been registered! Check your email for your password!";
} }}}}}}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Register</title>
<link href="stylesheets/index.css" rel="stylesheet" type="text/css" />
<script language=JavaScript>
function so(dis)
{
for (i=0;i<dis.elements.length;i++){
if (dis.elements[i].type=='submit')
dis.elements[i].style.visibility='hidden';
}
if(fs==false){
fs=true;
return true;
}else
return false;
}
function goaway()
{
for(i=0;i<document.forms.length;i++)
document.forms[i].onsubmit = function() {return so(this);};
}
</script>
</head>
<body onLoad="goaway();">
<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="header">Modern Mobsters</td>
</tr>
<tr>
<td height="18" align="center"><div id="sectionLinks">
<a href="index.php">Home</a><a href="register.php">Register</a><a href="lostpass.php">Lost Password</a><a href="/screens.php">Screenshots</a><a href="story.php">Story Line </a></div></td>
</tr>
<tr>
<td height="300" class="main"><p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<form action="" method="post" name="form2" id="form2">
<table width="300" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="130" height="40" class="bodytext"> Username: </td>
<td width="57%"><input name="reg_username" type="text" id="reg_username" maxlength="40" /></td>
</tr>
<tr>
<td class="bodytext">E-mail:</td>
<td><input name="email" type="text" id="email" value="" /></td>
</tr>
<tr>
<td class="bodytext">Re-Type E-mail: </td>
<td><input name="email1" type="text" id="email1" value="" /></td>
</tr>
<tr>
<td height="20" class="bodytext">Starting Location </td>
<td><select name="location" class="ddm" id="location" >
<option value="England" selected="selected">England</option>
<option value="China">China</option>
<option value="France">France</option>
<option value="Holland">Holland</option>
<option value="USA">USA</option>
<option value="Germany">Germany</option>
<option value="Canada">Canada</option>
<option value="South Africa">South Africa</option>
</select></td>
</tr>
<tr>
<td height="20" class="bodytext"><p>Script Check: <b><? print"$sc"; ?></b></p>
</td>
<td><input name="scriptcheck" type="text" id="scriptcheck" value="" />
<input type="hidden" value="<? print"$sc"; ?>" name="scrip"></td>
</tr>
<tr>
<td height="20" class="bodytext">Referal (optional) </td>
<td>
<? if(!$referal){ ?>
<input name="ref2" type="text" id="ref2" value="<? print"$referal"; ?>" maxlength="40" />
<? }else{ ?>
<input name="ref2" type="text" id="ref2" value="<? print"$referal"; ?>" maxlength="40" READONLY>
<? } ?> </td>
</tr>
<tr>
<td> </td>
<td> <input name="Submit" type="submit" class="submit" value="Register!" /> </td>
</tr>
</table>
</form> </td>
</tr>
</table>
<center>
</td>
<td> </td>
</tr>
<tr>
<td height="14"></td>
</tr>
</center>
</body>
</html>
Last edited by pukkalol : Feb 7th, 2008 at 5:18 pm.
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
I dont see anything wrong with your script. I even doubt if its a php problem. Try out with simple examples to check if you get mails instantly ! The problem might be with smtp server ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
Try out a simple mail function first. For eg,
Check if you get a mail instantly. If you do, then the problem is not with the configuration but in this script(above script). If you don't get an email, then the problem might be with smtp server. Ask your administrator for smtp address and update your php.ini file.
php Syntax (Toggle Plain Text)
<?php $to="id@email.com"; $from="From: id2@email.com"; $subject="Test mail"; $body="This is a test mail"; mail($to,$subject,$body,$from); ?>
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 240
huh! write a script to send the mail. Execute it and check if you get a mail !
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
ad advertising architecture backup beta blog business centro competition crash daniweb database decimal seperator thousand seperator when using sql server dell development doubleclick enterprise gentoo google hyper-v internet linux longhorn mail microsoft mmorpg news novell open php qmail red hat rhel security server server 2008 smtp software source spam suse vmware web windows windows server
- Previous Thread: Data feed url linking
- Next Thread: input data filtering



Linear Mode