Need you assistance to anyone who is willing to offer. I have been working on this script and can't get it to work.
The issue I'm having is the statement: - function validateSender($Address) {
-
if (strpos($Address, '@') !== FALSE && strpos($Address, '.') !== FALSE) {
-
return true;
-
}
-
-
else if (validateSender($_GET['Address']) == false) {
-
-
echo "The sender's e-mail address does not appear to be valid. Click your
-
browser's Back button to return to the message.";
-
}
-
else
-
return false;
-
}
The following code is suppose to validate if your missing either the "@" or "." in the PHPMail.html form.
Like I've said, I have been working on this code for the past 4 weeks, scrambled it from one place to another, not getting assistance from my professor, only that the answer is on a certain pg but hard and confusing as he had advised in an e-mail. I'm one of 3 others that are having issues with the same code. Please can someone out there help me with this. I would be grealy appraited. Thanks.
-------------------------------------------------------------------------------------------------------------- -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-
<title>PHP E-Mail</title>
-
<link rel="stylesheet" href="php_styles.css" type="text/css" />
-
</head>
-
-
-
-
<body>
-
-
-
<?php
-
function validateSender($Address) {
-
if (strpos($Address, '@') !== FALSE && strpos($Address, '.') !== FALSE) {
-
return true;
-
}
-
-
else if (validateSender($_GET['Address']) == false) {
-
-
echo "The sender's e-mail address does not appear to be valid. Click your
-
browser's Back button to return to the message.";
-
}
-
else
-
return false;
-
}
-
-
$From = "{$_GET['sender_name']} <{$_GET['sender_email']}>";
-
$To = $_GET['to'];
-
$Subject = $_GET['subject'];
-
$Message = $_GET['message'];
-
$Headers = "From: $From\r\n";
-
$Headers .= "MIME-Version: 1.0\r\n";
-
$Headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n";
-
$Headers .= "Content-Transfer-Encoding: 8bit\r\n";
-
if (strlen($Subject) > 40)
-
echo "<p>The subject must be 40 characters or less! Click your
-
browser's Back button to return to the message.</p>";
-
else {
-
//$MessageSent = mail($To, $Subject, $Message, $Headers);
-
$MessageSent = true;
-
if ($MessageSent) {
-
echo "<p>The following message was sent successfully:</p><hr />";
-
echo "<p><strong>From</strong>: $From</p>";
-
echo "<p><strong>To</strong>: $To</p>";
-
echo "<p><strong>Subject</strong>: $Subject</p>";
-
echo "<p><strong>Message</strong>: $Message</p>";
-
-
}
-
else
-
echo "<p>The message was not sent successfull!</p>";
-
}
-
?>
-
-
-
<hr /><p><a href="PHPEmail.html">Return to E-Mail Form</a></p>
-
</body>
-
</html>
-
PHPMail.html Form. -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<title>PHP E-Mail</title>
-
<link rel="stylesheet" href="php_styles.css" type="text/css" />
-
<meta http-equiv="content-type"
-
content="text/html; charset=iso-8859-1" />
-
</head>
-
<body>
-
<form action="PHPEmail.php" method="get">
-
<table frame="border" rules="cols" >
-
<tr>
-
<td valign="top">
-
<h2>Sender Information</h2>
-
<p>Name<br />
-
<input type="text" name="sender_name" size="40" /></p>
-
<p>E-Mail Address<br />
-
<input type="text" name="sender_email" size="40" /></p>
-
<hr /><h2>Recipients</h2>
-
<p>Enter each e-mail address on a separate line.</p>
-
<p>To<br />
-
<textarea name="to" rows="3" cols="30"></textarea></p>
-
<p>CC<br />
-
<textarea name="cc" rows="3" cols="30"></textarea></p>
-
<p>BCC<br />
-
<textarea name="bcc" rows="3" cols="30"></textarea></p>
-
</td>
-
<td valign="top">
-
<h2>Message Details</h2>
-
<p>Subject<br />
-
<input type="text" name="subject" size="53" /></p>
-
<p>Message<br />
-
<textarea name="message" rows="16" cols="40"></textarea></p>
-
<p style="text-align: center"><input type="submit" value="Send" /><input type="reset" /></p>
-
</td></tr>
-
</table>
-
</form>
-
</body>
-
</html>
8 1917
What error do you get, considering you get one at all?
Heya, Cutlass.
Changed thread title to better describe the problem (did you know that threads whose titles do not follow the Posting Guidelines actually get FEWER responses?).
Please use CODE tags when posting source code:
[CODE=php]
PHP code goes here.
[/CODE]
Hello cutlass
I'm not sure this can help you or not.. But try to use it, it may give you better ideas -
-
$email = "webmaster@mywebsite.com";
-
-
if (ereg("[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+", $email)) {
-
print "Right email format";
-
} else {
-
print "Wrong email format";
-
-
}
-
-
This script checks if the email user has entered is in a right format and tells you if @ or . is missing or not
One that works for me: -
function check_email($mail_address)
-
{
-
if (preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i", $mail_address))
-
return true;
-
else
-
return false;
-
}
-
Ronald
One that works for me: -
function check_email($mail_address)
-
{
-
if (preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i", $mail_address))
-
return true;
-
else
-
return false;
-
}
-
Ronald
The error I get is that it doesn't validate the "@" or "." when the user places the e-mail address in to form. If you don't put in one of the charachters required during the varifying process it just passes through and doesn't give an error.
I'm struggling this course cause I'm not into programming, I'm of networking, but need to take programming for a requirement. Our professor isn't giving us any ideas what so ever, we have placed everying in the right spot still nothing works. Two of us are trying to figure out what is going on, we have compared our code and still it's up the same.
The error I get is that it doesn't validate the "@" or "." when the user places the e-mail address in to form. If you don't put in one of the charachters required during the varifying process it just passes through and doesn't give an error.
I'm struggling this course cause I'm not into programming, I'm of networking, but need to take programming for a requirement. Our professor isn't giving us any ideas what so ever, we have placed everying in the right spot still nothing works. Two of us are trying to figure out what is going on, we have compared our code and still it's up the same.
hai..
i think it may be useful... -
if (document.form.email.value=="")
-
{
-
alert('Enter Email');
-
document.form.email.focus();
-
return false;
-
}
-
else
-
{
-
if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.form.email.value)))
-
{
-
alert('Improper mail format');
-
document.form.email.focus();
-
return false;
-
}
-
}
-
The error I get is that it doesn't validate the "@" or "." when the user places the e-mail address in to form. If you don't put in one of the charachters required during the varifying process it just passes through and doesn't give an error.
I'm struggling this course cause I'm not into programming, I'm of networking, but need to take programming for a requirement. Our professor isn't giving us any ideas what so ever, we have placed everying in the right spot still nothing works. Two of us are trying to figure out what is going on, we have compared our code and still it's up the same.
You got me all confused! What does the following email address check NOT do that you want it to do? Just test this code.
[php]
<?php
$array=array("You@ME.com", "Jon.doe@sssss.nl","PeteAtMysys.com");
for ($i=0;$i<count($array);$i++) {
if (!check_email($array[$i]))
echo "Error: ";
else
echo "Okay: ";
echo $array[$i].'<br />';
}
function check_email($mail_address)
{
if (preg_match("/^[0-9a-z]+(([\.\-_])[0-9a-z]+)*@[0-9a-z]+(([\.\-])[0-9a-z-]+)*\.[a-z]{2,4}$/i", $mail_address))
return true;
else
return false;
}
?>[/php]
Ronald
just add this to your code.html
<!-- by using indexOf( ) u can customize the condition about what are the valid email add u accepted.
-->
<script language="JavaScript">
<!--
function isValid() {
var email=document.form1.t1.value;
if (email.indexOf(' ')==-1
&& 0<email.indexOf('@')
&& email.indexOf('@')+1 < email.length
) return true;
else alert ('Invalid email address!')
return false;
}
//-->
</script>
<form name=form1
method=post
action="javascript:alert('The form is submitted.')"
onSubmit="return isValid()">
Your email:
<input type=text name=t1 size=20 >
<input type=submit value=Submit>
</form>[/code]
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John |
last post by:
What are the methods used in validating email addresses in Windows i.e
what are the replacement for getmxrr? does anyone have an example?
Thank you
John
|
by: Sue |
last post by:
<html>
Is there someone here that can help me validate the period as the
fourth from the last character in an email address. There is other
information and validation on the form I have to do but...
|
by: Doug |
last post by:
I'm a little confused by this functionality. It doesn't seem to be
behaving like it should.
I am using the following regular expression to validate email
addresses:...
|
by: orekinbck |
last post by:
Hi There
I have spent alot of time trying to get a masked text box to validate
e-mails, but with no success. Mainly because I can't figure out how to
account for the wide variety of different...
|
by: yochessyo |
last post by:
Hi,
I would like to validate email addresses.
I am not interested to validate it with a regex expression but from
the email server where the addresses are.
I would like to query this server and...
|
by: SAL |
last post by:
I am using a RegularExpressionValidator control on my ASP page, and I have
the ValidationExpression property set to "Internet E-mail Address". The
email address is valiated when the user puts in a...
|
by: gkountz |
last post by:
Hi:
I am brand new to css and a have a limited amount of working knowledge
regarding HTMl. This is primarily from using Frontpage. I recently
purchased Stylemaster, a css authoring program,...
|
by: John |
last post by:
Hi
I have this problem that client users enter emails incorrectly due to type
and either the domain name is invalid (Microsot.com instead of
Microsoft.com) or the syntax of the email...
|
by: rustyc |
last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-)
As I said over there:
... for a little side project at home, I'm writing a ham radio web site in...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |