Skip navigation links

MySQL Forums :: PHP :: Post and email form results to database


Advanced Search

Re: Post and email form results to database
Posted by: Tom Garrison ()
Date: April 09, 2008 04:24PM

I would also like the answer to this question. "Supposedly", my programmer set up the account creation page to send the username and password to the user. But, it's not working. All else does so that the information is in the db. Following is the code of the page that is to send the user their information:

<?
include("header.php");
?>


<!--<form action="order_detail.php" name="form2" id="form2" method="post">
<input type="hidden" name="user_id" value="" />
<input type="hidden" name="plan_id" value="" />
</form>-->
<!-- <script>
function dopost(user_id,plan_id,cost)
{alert('hello');
if(cost==0 || cost=="")
{
document.form2.action="paypal/paypal.php";
}
document.form2.user_id.value=user_id;
document.form2.plan_id.value=plan_id;
document.form2.submit();
}
</script>-->

<?

$strheadline="";
$id=0;
$user_full_name="";
$user_email="";
$user_name="";
$user_password="";
$date_of_joining="";
$user_address="";
$user_city="";
$user_state="";
$user_country="";
$user_zipcode="";
$c_name="";
$user_is_active="0";
$mem_phone="";
$msg="";
$a=0;
$flag=0;
$error=false;

$_SESSION["timestamp"]=(isset($_SESSION["timestamp"])==true)?$_SESSION["timestamp"]:"";

if(isset($_GET["msg"]))
$msg=$_GET["msg"];

if(isset($_POST['Submit']))
{
$id=$_POST["id"];
if (isset($_POST["user_full_name"])) $user_full_name=$_POST["user_full_name"];
if (isset($_POST["user_name"])) $user_name=$_POST["user_name"];
if (isset($_POST["user_email"])) $user_email=$_POST["user_email"];
if (isset($_POST["user_password"])) $user_password=$_POST["user_password"];
if(isset($_POST["date_of_joining"])) $date_of_joining=$_POST["date_of_joining"];
if(isset($_POST["user_address"])) $user_address=$_POST["user_address"];
if(isset($_POST["user_city"])) $user_city=$_POST["user_city"];
if(isset($_POST["user_state"])) $user_state=$_POST["user_state"];
//if(isset($_POST["user_country"])) $user_country=$_POST["user_country"];
if(isset($_POST["user_zipcode"])) $user_zipcode=$_POST["user_zipcode"];
if(isset($_POST["phone_cc"])) $mem_phone=$_POST["phone_cc"].'-';
if(isset($_POST["phone"])) $mem_phone.=$_POST["phone"];

$k1="select * from tbl_users where mem_username='$user_name' and mem_is_deleted=0" ;
$p1=mysql_query($k1);

if(mysql_num_rows($p1)==0)
{
$k2="select * from tbl_users where mem_email='$user_email' and mem_is_deleted=0";
$p2=mysql_query($k2) or die(mysql_error());
if(mysql_num_rows($p2)>0)
{
$a=1;
$msg="Please choose another E-Mail Id";
}
}

else if (mysql_num_rows($p1)>0)
{
$a=1;
$msg="Please choose another User name";
}

if($a!=1){
$result=mysql_query($sql="Insert into tbl_users set
mem_full_name='$user_full_name',
mem_username='$user_name',
mem_email='$user_email',
mem_password='$user_password',
mem_doj=now(),
mem_address='$user_address',
mem_city='$user_city',
mem_state='$user_state',
mem_country='$user_country',
mem_is_active=1,
mem_pay_status=0,
mem_phone='$mem_phone',
mem_zipcode='$user_zipcode'") or die("Error Occured While Creating User");

$msg=$result?"You have been registered Successfully":"Sorry! Problem in registration! Please try again";
if($result) {
header("location:success.php");
die;
}

}
}


?>

<div class="indmain">
<div class="indextxt">
<div class="fullcenter">
<table width="100%" border="0" cellspacing="0" cellpadding="0" >

<tr>
<td bgcolor="#F5F5F5" ><img src="images/dot.gif" alt="" width="4" height="3" /></td>
</tr>

<tr>
<td height="36" style="padding-left:8px" bgcolor="#F5F5F5" class="headingwhite"><strong>User Registration - Step 1 of 2</strong></td>
</tr>


<tr>
<td bgcolor="#F5F5F5"><img src="images/dot.gif" alt="" width="4" height="3" /></td>
</tr>
<tr>
<td bgcolor="#F5F5F5" height="5"></td>
</tr>
<tr>
<td height="173" style="padding-left:5px; padding-top:8px;border:#CECECE 1px solid; " >
<table width="98%" border="0" align="center" cellpadding="1" cellspacing="1">
<tr>
<td width="100%" valign="top" ><table class="txt10" width="100%" border="0" cellspacing="0" cellpadding="0">

<?
if($flag==0)
{
?><tr>
<td width="50" align="left" valign="middle"><span class="h1_black"> <br />
</span></td>
<td width="100%" align="left" valign="middle" class="text"><strong>Step 1:</strong> Register your profile here. (This step does <u>not</u> create your listing) </td>
</tr>
<tr>
<td colspan="2" align="left" valign="bottom" style="padding:8px"><table width="100%" border="0" cellspacing="0" cellpadding="0" >
<?
if($msg!="")
{
?>
<tr>
<td id="msg" class="text"><span class="style1"><?=$msg;?></span></td>
</tr>

<?
}
?>

<tr>
<td><form action="registernow.php" method="post" name="form1" id="form1" onsubmit="return check(this);" enctype="multipart/form-data">

<input type="hidden" name="site_sub_domain" value="<?=isset($site_sub_domain) ? $site_sub_domain : "" ?>" />
<input type="hidden" name="site_main_domain" value="<?=isset($site_main_domain) ? $site_main_domain : "" ?>" />
<input type="hidden" name="timestamp" id="timestamp" value="<?=time();?>" />
<input name="page" type="hidden" id="page" value="<?=isset($p) ? $p : ""?>" size="30" />
<input type="hidden" name="c_name" id="c_name" />


<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tblheading10" >
<tr>
<td height="30" align="left"><span class="text">User Name</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30"><input name="user_name" type="text" id="user_name" title="User Name" lang="Must" value="<?=$user_name;?>" size="31"/></td>
<td width="2%">&nbsp;</td>
</tr>
<tr>
<td height="30" align="left"><span class="text">Password</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30"><input name="user_password" type="password" id="user_password" title="Password" lang="MUST" value="<?=$user_password;?>" size="31" xml:lang="MUST" /></td>
<td>&nbsp;</td>
</tr>

<tr>
<td width="17%" height="30" align="left"><span class="text">Name</span><span class="style1">*</span></td>
<td width="2%" height="30">&nbsp;</td>
<td width="58%" height="30"><input name="user_full_name" size="31" type="text" id="user_full_name" title="Name" lang="MUST" value="<?=$user_full_name;?>"/></td>
<td width="2%">&nbsp;</td>
</tr>
<tr>
<td height="30" align="left"><span class="text">Email</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30"><input name="user_email" type="text" id="user_email" title="E-Mail" lang="MUSTEMail" value="<?=$user_email;?>" size="40" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="30" align="left"><span class="text">Address</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30">
<textarea name="user_address" id="user_address" title="Address" lang="MUST" rows="3" cols="30" ><?=$user_address;?></textarea>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="30" align="left"><span class="text">State</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30"><select name="user_state" id="user_state" lang="MUST" title="State" >
<option value="">Select a State</option>
<?
$rs=mysql_query($sql="select * from tbl_location where length(loc_code)=5 and loc_status=1");
while($row=mysql_fetch_array($rs)){
echo "<option value='".$row['loc_code']."' >".$row['loc_name']."</option>";
}

?>
</select> </td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="30" align="left"><span class="text">City</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30"><input name="user_city" type="text" id="user_city" title="City" lang="MUST" value="<?=$user_city;?>" size="25" xml:lang="MUST" /></td>
<td>&nbsp;</td>
</tr>
<!--<tr>
<td height="30" align="left"><span class="text">Country</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30"><input name="user_country" type="text" id="user_country" title="Country" lang="MUST" value="" size="25" xml:lang="MUST" />


[listbox.selectedIndex].text

<script language="javascript" type="text/javascript">
function country(obj)
{
value=obj.options[obj.selectedIndex].text;

document.getElementById("c_name").value=value;

}

</script>


<select name="user_country" id="user_country" lang="MUST" title="Country" onchange='country(this);'>
<option value="">Select a Country</option>
<option value="Åland Islands">Åland Islands</option>
<option value="Afghanistan">Afghanistan</option>

</select> </td>
<td>&nbsp;</td>
</tr>-->


<tr>
<td height="30" align="left"><span class="text">Zip Code</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30"><input name="user_zipcode" type="text" id="user_zipcode" title="Zipcode" lang="MUST" value="<?=$user_zipcode;?>" size="25" xml:lang="MUST" /></td>
<td>&nbsp;</td>
</tr>
<tr>
<td height="30"><span class="text">Phone No.</span><span class="style1">*</span></td>
<td height="30">&nbsp;</td>
<td height="30"><input name='phone_cc' type='text' id='phone_cc' size="8" lang="MUSTINT" title="Area Code" alt="Area Code" />


<span style="HEIGHT: 26px"><strong>-
<input name='phone' type='text' id='telNoCc' size="15" title="Telephone Number" lang="MUSTINT" alt="Telephone Number" />
</strong></span></td>
<td>&nbsp;</td>
</tr>
<tr><td colspan="3">&nbsp;</td></tr>

<tr>
<td height="30" align="center">&nbsp;</td>
<td height="30">&nbsp;</td>

<td height="30" align="right"><input type="submit" name="Submit" class="button" value="Register" /> and Sign In for <strong>Step 2</strong></td>
<td>&nbsp;</td>
</tr>
<tr>
<td valign="middle">&nbsp;</td>
<td>&nbsp;</td>
<td><span class="text">(<span class="style1">*</span>)Sign Indicates that these fields are Required. </span></td>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="4"><input type="hidden" name="id" value="<?=$id;?>" /></td>
</tr>
</table>

</form></td>
</tr>
</table>
<?
}
?> </td>
</tr>
</table></td>
</tr>
</table></td>
</tr>

</table>
</div></div></div>
<script language="javascript" type="text/javascript">
//<![CDATA[
function check(form)
{


var returnvalue=validateForm(form);
if(returnvalue==true)
{

var reg = /^[0-9]*$/;
if(!reg.test(document.getElementById('telNoCc').value))
{

alert("Enter Valid Phone Number");
document.getElementById('telNoCc').focus();
return false;
}



}
else
{
return false;
}
return true;


}
//]]>
</script>
<!--Right featured listing-->
<? include("right.php"); ?>
<!--Right featured listing-->
<? include("footer.php"); ?>



Can you tell from the above if there is the "correct" method to send/email the user the username and passwords for their account they just create?

Thanks.

Options: ReplyQuote


Subject Written By Posted
Post and email form results to database Steve A. 04/08/2008 02:43PM
Re: Post and email form results to database Tom Garrison 04/09/2008 04:24PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.