PDA

View Full Version : cant see the forest for the trees - verifying fields



davidundalicia
04-25-2006, 05:42 PM
Hi all,
I am a great believer in self help and therefore have searched and read and viewed and visited other peoples websites who have had this same problem.
.
Using pablos very good description, I have created my contact.bvp form
and also created my confirm.bvp form saved as php.
Published both and all are working OK......
.
Now, I would like to have the 3 simple fields (name, email, and comments) verified using the (If strlen ) coding as found during above searches.
.
Is it just a case of adding these simple lines or is something else required as I
keep getting error messages.
.
I have reverted to the original code for now
until some kind person points me in the right direction......

Girlonthehill
04-25-2006, 05:54 PM
Greetings David,

Aren't they a nightmare? I've found this which deals with validation of correct format of email and a contact name:

http://www.vodahost.com/vodatalk/forms/5561-script-help.html Post #9

One of Naval's, obviously, maybe you could check your validation bits against it? If it doesn't help - send up a flare!

davidundalicia
04-25-2006, 06:08 PM
Hi Amanda, where the heck are the flares !!!!!
.
its something simple like this that I am looking for

if (strlen($COMMENT) == 0 )
{
header("Location: upload_error.html");
exit;
}

but when I copy and paste into my existing confirm.bvp and republish as php
thats when I get a the warning message.....

I have viewed most of navals posts but all seem to involve notepad and ftp
and I am trying to keep this simple......

davidundalicia
04-25-2006, 06:19 PM
oh.... heres my original script for those that cannot read my mind......oops
.

<?PHP
$email = $HTTP_POST_VARS[email];
$mailto = "me@myplace.com";
$mailsubj = "Feedback from form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

Girlonthehill
04-25-2006, 07:02 PM
oh.... heres my original script for those that cannot read my mind......oops
.

<?PHP
$email = $HTTP_POST_VARS[email];
$mailto = "me@myplace.com";
$mailsubj = "Feedback from form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

The simplest way, for most, is to paste the script into notepad (start>all programs>accessories>notepad). Save as (change the file type to All Files) and save as example.php

Open the file publish tool in any BV page (left hand menu - globe with arrow pointing north). Double click the box that appears and browse for your php file don't worry where on the page it is as it only acts as a basket to carry files and does not show up on the page). Then publish the BV page, as normal. When the page is successfully publish - delete the file upload box from your BV page.

This should have placed your php script safely in your public.html folder (or wherever you have saved it) from where your pages can access it.

If I am, in an effort to help, 'teaching my Grandmother to suck eggs', I apologise! I hope this does assist you.

davidundalicia
04-25-2006, 07:31 PM
Hi amanda,
Please dont apologise as any reply is allways useful....

The whole point of this exercise is to try and find a way to verify form fields
without using notepad, ftp or the carrier. In other words, to continue the simple way of creating forms as described by Pablo and continued by Naval.
.
In my mind, there have been many, many posts for help on this same subject
and if we could simplify this by using the publishing method then we would be helping a lot more people.....
.
I am fairly new with bv and vh but I am learning something new each day...
Here is my latest attempt
<?PHP
@$name = addslashes($_POST['name']);
@$email = addslashes($_POST['email']);
if (strlen($name) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($email) == 0 )
{
header("Location: error.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
header("Location: error.html");
exit;
}
$email = $HTTP_POST_VARS[email];
$mailto = "admin@mvtinia.com";
$mailsubj = "Feedback from mvpalma1 form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
?>

Can Anyone point me in the right direction ????

navaldesign
04-25-2006, 07:45 PM
<?PHP
@$name = addslashes($_POST['name']);
@$email = addslashes($_POST['email']);
if (strlen($name) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($email) == 0 )
{
header("Location: error.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
header("Location: error.html");
exit;
}
$email = $HTTP_POST_VARS[email]; Delete this line. You have already defined $email above
$mailto = "admin@mvtinia.com";
$mailsubj = "Feedback from mvpalma1 form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("Location: thankyou_page.html");

?>

All the rest seems correct, BUT YOU HAVE TO UPLOAD IT IN THE NOTEPAD METHOD: the headers in the script might conflict with the html code if you paste it in a BV page. That's why i have added the line in red

davidundalicia
04-25-2006, 07:52 PM
Thanks naval, will try as you have suggested.....

navaldesign
04-25-2006, 08:03 PM
Please create and publish the thankyou page. You will need it to redirect the visitor after submission.

davidundalicia
04-25-2006, 10:08 PM
naval, I now have my contact page, my confirm page and a php file uploaded but with the below I still am getting a warning message....

can you check below.....thanks....

<?PHP
@$name = addslashes($_POST['name']);
@$email = addslashes($_POST['email']);
if (strlen($name) == 0 )
{
header("Location: error.html");
exit;
}
if (strlen($email) == 0 )
{
header("Location: error.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
header("Location: error.html");
exit;
}
$mailto = "admin@mvtinia.com";
$mailsubj = "Feedback from mvpalma1 form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n";
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("Location: confirm.html");
?>

davidundalicia
04-27-2006, 12:18 AM
Latest information......

name and email fields Verification are now working......thanks naval

Contact.bvp page (action=contact.php - method=post - encoding type=blank)

nameerror.html page - emailerror.html page - confirm.html page

contact.php

<?PHP
@$name = addslashes($_POST['name']);
@$email = addslashes($_POST['email']);
if (strlen($name) == 0 )
{
header("Location: nameerror.html");
exit;
}
if (strlen($email) == 0 )
{
header("Location: emailerror.html");
exit;
}
if (! ereg('[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+', $email))
{
header("Location: emailerror.html");
exit;
}
$mailto = "admin@mvtinia.com";
$mailsubj = "Feedback from mvpalma1 form";
$mailhead = "From: $email\n";
reset ($HTTP_POST_VARS);
$mailbody = "Values submitted from web site form:\n";
while (list ($key, $val) = each ($HTTP_POST_VARS))
{
$mailbody .= "$key : $val\n"
}
mail($mailto, $mailsubj, $mailbody, $mailhead);
header("Location: confirm.html");
?>

ALL problems now resolved.........