hello,


i want to do small mail concept. what it zzzzz means admin sends registration form to user mails. in that mail user can register their account . my doubt is is there any chance to apply validations in mail. below is my script.

<?
ob_start();
extract($_REQUEST);
include("includes/class.phpmailer.php");


if($_POST)
{
/////////////////////////////////////////////////////////////////////////////////////////////
///////             send registrationform to user          /////////
///////////////////////////////////////////////////////////////////////////////////////////

	
		
		
$sitename="http://localhost/murali/";
	
		//this subject will be visible only for you
		$sub = "".$name." invites you to www.murali.com";
	
		$msg = "<html><head>
		<script>
		function valide()
		{
		if(document.formz.username.value=='')
		{
		alert('enter username');
		document.formz.username.focus();
		return false;
		}
		if(document.formz.password.value=='')
		{
		alert('enter password');
		document.formz.password.focus();
		return false;
		}
		else
		{
		window.document.formz.action='http://localhost/murali/';
		}
		}
		</script>
		
		
		</head>
		
		<body>
		<table width='100%'  border='0' cellspacing='0' cellpadding='0'>
					  <tr>
						<td height='8'></td>
					  </tr>
					  <tr>
						<td style='font-family:Verdana; font-size:12px; font-weight:normal; color:#000000' align='left'>
							<br>
							
							    <p>".$transl2." </p><br>
								
								<form name='formz' action='' method='post' onsubmit='return valide();'>
								<table align='center'>
								<tr>
								<td>username</td>
								<td><input type='text' name='username'></td>
								</tr>
								<tr>
								<td>password</td>
								<td><input type='password' name='password'></td>
								</tr>
								<tr>
								<td>Address</td>
								<td><input type='address' name='address'></td>
								</tr>
								<tr>
								<td>&nbsp;</td>
								<td><input type='submit' name='submit' value='submit' ></td>
								</tr>
								</table>
								</form>
									</td>
					  </tr>
					  
					  
					  <tr>
						<td height='8'></td>
					  </tr>
					  <tr>
						<td height='8'></td>
					  </tr>
					 
					  <tr>
						<td height='8'></td>
					  </tr>
					  <tr>
						<td align='left' style='font-family:Verdana; font-size:12px; font-weight:bold; color:#47493F'>Regards,<br>
						murali.
						</td>
					  </tr>
					  <tr>
						<td height='8'></td>
					  </tr>
					  <tr>
						<td height='8'></td>
					  </tr>
					   
					  
					  
					  <tr>
						<td height='4'></td>
					  </tr>
					</table></body>
					</html>";
			
			$msg = stripslashes($msg);
			
			
			
			//include("includes/class.smtp.php");
			//include("includes/constants.php");
		
			$SmtpAuth = 1; // 1 For IsSMTP() and 0 For IsMail()	
			
			$mail = new PHPMailer();
			
			//$mail->IsMail();
			if($SmtpAuth == 0)
			{
				$mail->IsMail();
			} 
			else 
			{
				$mail->IsSMTP();
				$mail->Host = "xxxx";  // specify main and backup server
				$mail->SMTPAuth = true;     // turn on SMTP authentication
				$mail->Username = "xxxx";  // SMTP username
				$mail->Password = "xxxx"; // SMTP password
			}                                      // set mailer to use SMTP
			
			
			
				$mail->From     = $_POST[email];
				$mail->FromName = $_POST[name];
				$mail->AddAddress($_POST[useremail]);
/*				$mail->AddCC($resNewsUsers["emailid"]);
				$mail->AddBCC($resNewsUsers["emailid"]);*/
				$mail->IsHTML(true);                                  // set email format to HTML
				$mail->Subject = $sub;
				$mail->Body = $msg;
				$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
				$mail->Send();
			
		$send=1;
/////////////////////////////////////////////////////////////////////////////////////////////
///////            end          /////////
///////////////////////////////////////////////////////////////////////////////////////////

}
?>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
   
  </head>
  <body>
  <form name="formx" method="post">
  <center>you can send mails in any languages</center>
 
  <? if($send==1)
  {
  ?>
  successfully sent.
  <?
  }
  ?>
  
     

<br>
name:    
<input type='textbox' id="name" name="name"/><br>
<br>
email:                                                                           
<input type='textbox' id="email" name="email"/><br>
<br>useremail:       <input type='textbox' id="useremail" name="useremail"/>
<br>Body<br>           <textarea id="transl2" name="transl2" style="width:600px;height:200px"></textarea>
	<input type="submit" name="submit" value="murali"></input>
    <br><div id="errorDiv"></div>
	</form>
  </body>
</html>

see once in mail body there is registration form. in that above javascript is there. in my mail i am not entering any fields just clicking submit button then it it zzz redirecting to website. so how i can validate that fields in mail only. any body give suggestions

Recommended Answers

All 7 Replies

Your html code will work well but, javascript code may be blocked by mail client. So it will not work as per you expectations.

Your html code will work well but, javascript code may be blocked by mail client. So it will not work as per you expectations.

you have any idea about validation in the user mail ?

1)i know the one solution what it is means form action redirects to my webpage with values. if it redirect null values then i will redirects to registration form in my website.

2)another solution is create hyperlink and redirect to direct registration form which is in website.

i know these things. but i want to use javascript or any thing for validation in usermail . is it possible ?

You may use javascript in your mail code but its exeution will depend on browser/email client setting. It may prompt/warn user to execute javascript.

Better option
1) create simple html form. give submit button without validation send it as mail.
2) user fills form in his email and submits.
3) action page will be on your website. validate fields on action page.
4) if user doesnt fill form properly then redirect it to similar form page(with validation code) as sent in email. if user enter everything properly then insert in your database.

You can validate email addresses before actually sending emails.

First you can validate the syntax. That is check if the email address is of valid format.

Then you can try validation via SMTP:
http://code.google.com/p/php-smtp-email-validation/

As for validation within emails, to see if they were opened, you can embed images that are actually PHP files.

eg:

<img src="http://yoursite.com/validate.php?id=emailid" />

Then have the php page http://yoursite.com/validate.php log the opening of the email.

However, some email clients will disable images by default.

If you use JavaScript, it will most likely not work.

You may use javascript in your mail code but its exeution will depend on browser/email client setting. It may prompt/warn user to execute javascript.

Better option
1) create simple html form. give submit button without validation send it as mail.
2) user fills form in his email and submits.
3) action page will be on your website. validate fields on action page.
4) if user doesnt fill form properly then redirect it to similar form page(with validation code) as sent in email. if user enter everything properly then insert in your database.

first i got these all solutions. but i dont want these solutions.thats why i mentioned above is it possible validation in mail using javascript .

mysql_num_rows(): supplied argument is not a valid MySQL result resource in J:\wamp\www\All_Basic\insert_data_table.php on line 37

code:

function check_user($fullname){
    $result_check = mysql_query("select * from site_user where fullname = '$fullname'");
    //$result = mysql_query ( $sql);
    $rows = mysql_num_rows($result_check);
    if ($rows>0){
            echo "there are already $full exits. plz try another name.";
            exit;
        }
}

first i got these all solutions. but i dont want these solutions.thats why i mentioned above is it possible validation in mail using javascript .

Yes, it is possible. BUT, as mentioned by urtrivedi, most email apps will block javascript by default, so in most cases it won't work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.