473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

php form 'sometimes' works

Can someone please help me with this?

I have a form that I use on most of my sites - they all worked fine -
then one day they stopped working. here is the code

<?
$name=$_POST['name'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$email = preg_replace( '/[\r\n]/', '', $email );
$comment=$_POST['comment'];
$to="my****@yahoo.ca";

$message="The E-mail is From:$name\n\nTheir Phone Numbers
is:$phone\n\nTheir e-mail address is: $email\n\nThey
wrote:\n\n$comment";
if(mail($to,"E-mail from myname.ca",$message,"From:$email\n")){
echo "Thank you $name. Your Information has been sent successfully.
We will contact you shortly.";
}else{
echo"There was a problem sending the messages. <br> <a href='mailto:
my****@yahoo.ca'>Please click here to e-mail us</a>";
}
?>

I know the page is getting the info from the first page because if I
change the last line to include $name $phone etc it all appears.
The preg_replace is purely for spammers.

Where is the error? Any ideas? An aside here - On two of my sites it
runs fine (a different hosting company though) but this hosting company
refuses to say it's on their end? - Either way I need this to start
working yesterday. Please help.

michael

Jan 10 '06 #1
8 1571
bokke wrote:
Can someone please help me with this?

I have a form that I use on most of my sites - they all worked fine -
then one day they stopped working. here is the code

<?
$name=$_POST['name'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$email = preg_replace( '/[\r\n]/', '', $email );
$comment=$_POST['comment'];
$to="my****@yahoo.ca";

$message="The E-mail is From:$name\n\nTheir Phone Numbers
is:$phone\n\nTheir e-mail address is: $email\n\nThey
wrote:\n\n$comment";
if(mail($to,"E-mail from myname.ca",$message,"From:$email\n")){
echo "Thank you $name. Your Information has been sent successfully.
We will contact you shortly.";
}else{
echo"There was a problem sending the messages. <br> <a href='mailto:
my****@yahoo.ca'>Please click here to e-mail us</a>";
}
?>

I know the page is getting the info from the first page because if I
change the last line to include $name $phone etc it all appears.
The preg_replace is purely for spammers.

Where is the error? Any ideas? An aside here - On two of my sites it
runs fine (a different hosting company though) but this hosting company
refuses to say it's on their end? - Either way I need this to start
working yesterday. Please help.

michael

A quick thought...
In some systems, <? may not be sufficient. Have you tried it with <?php
at the start. Syntactically, the PHP is fine.

-david-

Jan 10 '06 #2
Just tried it to no avail - what do you do when you write code that
works but ... doesn't...on certain servers?
thanks for trying david

michael

Jan 10 '06 #3
Following on from bokke's message. . .
Just tried it to no avail - what do you do when you write code that
works but ... doesn't...on certain servers?
thanks for trying david

michael

Ummm. I can think of more productive things than writing to c.l.p and
only saying "it doesn't work". Do you send a postcard to the local fire
brigade withjust the words "There's a fire!" and expect them to be able
to respond.

Hint. You need directions to your fire. Try isolating it's locality
and understanding exactly what's going on in that area.
--
PETER FOX Not the same since the bridge building business collapsed
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Jan 10 '06 #4
bokke wrote:
Just tried it to no avail - what do you do when you write code that
works but ... doesn't...on certain servers?
thanks for trying david

michael

First off, I run phpinfo on all servers.
Then I try to reproduce the environment that fails on my system.
Given what I know about your issue now, I would suspect a PHP versioning
issue.

-david-

Jan 10 '06 #5
Pont taken Peter,

But this is the first time I've had an issue I culdn't work out by just
playing with the code? how do I ....
"Try isolating it's locality and understanding exactly what's going on
in that area."

thanks for your ... help?

Jan 10 '06 #6
bokke wrote:
Can someone please help me with this?

I have a form that I use on most of my sites - they all worked fine -
then one day they stopped working. here is the code

<?
$name=$_POST['name'];
$phone=$_POST['phone'];
$email=$_POST['email'];
$email = preg_replace( '/[\r\n]/', '', $email );
$comment=$_POST['comment'];
$to="my****@yahoo.ca";

$message="The E-mail is From:$name\n\nTheir Phone Numbers
is:$phone\n\nTheir e-mail address is: $email\n\nThey
wrote:\n\n$comment";
if(mail($to,"E-mail from myname.ca",$message,"From:$email\n")){
echo "Thank you $name. Your Information has been sent successfully.
We will contact you shortly.";
}else{
echo"There was a problem sending the messages. <br> <a href='mailto:
my****@yahoo.ca'>Please click here to e-mail us</a>";
}
?>

I know the page is getting the info from the first page because if I
change the last line to include $name $phone etc it all appears.
The preg_replace is purely for spammers.

Where is the error? Any ideas? An aside here - On two of my sites it
runs fine (a different hosting company though) but this hosting company
refuses to say it's on their end? - Either way I need this to start
working yesterday. Please help.

michael


"I had a car that used to run, but one day it stopped working. Can
anybody tell me what's wrong with it?"

If you gave us the slightest hint of what it actually does when it
'stops working' we might be able to make some useful suggestions.

Colin
Jan 10 '06 #7
I don't know how appropriate this is but - there was no error on the
page. This morning it works fine. I was sure it was with the server
(Yesterday my MYSQL went down) but the hosting company assured me
nothing had changed on their end - so I spent several hours trying
different ways to use an online form, until I finally gave up and
posted here. And low and behold two days later its working like a
charm.

My recommendation is DONOT sign up with http://hostingca.com/ ! They
truly are crap! I know it's an imperfect world and 99.9% Network
Uptime Guarantee doesn't mean that you will have e-mail 7 days a week
or access to your database sometimes or that your online forms may just
on day stop working - but hey your site never goes down - it just
doesn't work!!!

I'm ranting - - sorry I could not be more specific but the code above
was the extent of the page and I could not work out why it worked on
Friday but stopped working on Saturday.

thanks for your help

Jan 11 '06 #8
bokke wrote:
I don't know how appropriate this is but - there was no error on the
page. This morning it works fine. I was sure it was with the server
(Yesterday my MYSQL went down) but the hosting company assured me
nothing had changed on their end - so I spent several hours trying
different ways to use an online form, until I finally gave up and
posted here. And low and behold two days later its working like a
charm.

My recommendation is DONOT sign up with http://hostingca.com/ ! They
truly are crap! I know it's an imperfect world and 99.9% Network
Uptime Guarantee doesn't mean that you will have e-mail 7 days a week
or access to your database sometimes or that your online forms may just
on day stop working - but hey your site never goes down - it just
doesn't work!!!

I'm ranting - - sorry I could not be more specific but the code above
was the extent of the page and I could not work out why it worked on
Friday but stopped working on Saturday.

thanks for your help


I'm glad your problem went away, but I repeat:

You never told us what you meant by 'stopped working'.

Please, if you have occasion to post a problem here again, be more specific!
Colin
Jan 15 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Eric | last post by:
Hello everyone, I am pretty much newbie to ASP so please bear with me as I explain my problem. I currently have a main form which displays data queried from a SQL database. From that main page...
14
by: threeflush | last post by:
I'm supporting an ASP legacy application and need to implement "autosave" functionality. I have two frames, one that holds tabs displaying different pages a user can select, and the other that...
1
by: Steve Miles | last post by:
I've got a form with a combo box and begin/end dates. When any of the three are changed I set a subform's recordsource so the records returned are filtered based on the three fields. The syntax...
3
by: Bruce Dodds | last post by:
I'm trying to set a tabledef object from a form object's RecordSource in Access 97. This is the code: Public Function EditSubjectForm(ByVal frm As Form) As Boolean Dim db As Database, tbl As...
6
by: peter hansen | last post by:
By changing the backgroundimage of a form into a picture and then enable the TransparencyColor you can make a form as a cirkel etc (the form has the same 'form' as the picture has). I have then...
5
by: Ron | last post by:
Hi All, I've got a form called frmCust that has a subform on it called sfrmBalance. sfrmBalance's control source is a query called qryTrans4CustBal. sfrmBalance has one field on it called...
10
by: morangolds | last post by:
Hi, I've been having a problem with C++ Windows Forms apps not "ending" when you close the form window. I've searched about this problem all over the place and most searches have lead me to...
7
by: Rotsey | last post by:
Hi, I am loading a tab control on a form. The code loads textboxes and comboboxes and checkboxes, normal data entry form that loads a table row of data. I have a combo on the form above the...
12
by: OldBirdman | last post by:
I have a form=Options, which is Bound, Modal, PopUp. This form consists of many tabs, each with many, varied controls. I have a Frame with 3 options, using radio buttons. Works fine. But if...
2
by: rudiedirkx | last post by:
Gents, I have a problem (only in Safari) with the onsubmit in webforms. This topic covers the same subject: http://bytes.com/topic/javascript/answers/166542-onsubmit-safari but not as detailed as...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.