LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-29-2009, 07:40 PM   #1
picklepie1
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Rep: Reputation: 0
Question Portion of client's PHP script not working - please help


Hello,
I have a client whose web site offers a page where customers can make spa reservations. The PHP script was created by someone else who is no longer working on the site. The client has sent her problem to me but I am the designer not the programmer, so I'm not sure where the problem lies.

She said the section where the customer states their requested appointment day and time (1st choice and 2nd choice) comes up blank on their end.

Can someone please take a look at this pasted PHP script and see if you can detect a problem with those lines? Thank you in advance to anyone who's able to offer some assistance.

PHP Code:
<?php
$to 
"emailhere@yahoo.com";
$body "Nail Spa - Reservation Request\n\n";
$body $body."Name: ".$_REQUEST['flg4']."\n";
$body $body."Contact via ".$_REQUEST['flg3']."\n";
$body $body."\n\nDetails\n";
$body $body."eMail: ".$_REQUEST['flg5']."\n";
$body $body."Home: ".$_REQUEST['flg6']."\n";
$body $body."Work: ".$_REQUEST['flg7']."\n";
$body $body."Cell: ".$_REQUEST['flg8']."\n";
$body $body."\n\nAppointment\n";
$body $body."1st Choice: ".$_REQUEST['flg11']." - ".$_REQUEST['flg9']." - ".$_REQUEST['flg10']."\n";
$body $body."2nd Choice: ".$_REQUEST['flg14']." - ".$_REQUEST['flg12']." - ".$_REQUEST['flg13']."\n";
$body $body."Other Days: ".$_REQUEST['flg15']."\n";
$body $body."\n\nSelect Spa Services\n";
$i=0;
while (isset(
$_REQUEST['opt'.$i])) {
    
$body $body."Option: ".$_REQUEST['opt'.$i]."\n";
    
$i++;
}
$body $body."\n\nComments\n";
$body $body.$_REQUEST['flg16']."\n";
$body $body."\n";
$body $body."\n\nMany Thanks!";
$subject "Nail Spa Reservation Request\n\n";
if (
mail($to$subject$body)) {
  echo(
"Request Submitted. You will be contacted by one of our staff for appointment confirmation.");
 } else {
  echo(
"Request Failed. Please try again.");
 }
 
$to "emailhere@yahoo.com";
 if (
mail($to$subject$body)) {
 } else {
 }
 if (
mail(trim($_REQUEST['flg5']), $subject$body)) {
 } else {
 }
?>
 
Old 04-29-2009, 09:46 PM   #2
Acron_0248
Member
 
Registered: Feb 2006
Location: Venezuela
Distribution: Gentoo
Posts: 453

Rep: Reputation: 33
The code doesn't tell anything about where it gets its values beyond using the deprecated $_REQUEST global variable, assuming it comes from a POST or even GET request made by a html form, the php code itself doesn't seem to be the problem, more likely the html form (or whatever they're using to send the values) is where the problem lies, maybe it was redesigned or control attributes were changed.

However, the code you posted only leads to assumptions about what might be wrong and where it might be failing so, based on that code, there's not much that one can say to you.

A point of note, the following doesn't seem to have any reason to exist:
PHP Code:
 $to "emailhere@yahoo.com"
 if (
mail($to$subject$body)) { 
 } else { 
 } 
 if (
mail(trim($_REQUEST['flg5']), $subject$body)) { 
 } else { 
 } 
That might be an indication about code made for testing only purposes and not production or maybe someone messed up the script(?)
 
Old 04-29-2009, 11:11 PM   #3
picklepie1
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for your response, Acron. Most of it is Greek to me. I really REALLY don't understand PHP. Are you saying that bit of script can simply be removed without disturbing the rest of the code?

And you don't think the problem lies with this PHP code... the way the code is written, the user should be able to submit their desired reservation day and time? So I should be checking the other html file associated with this file instead, is that right?

I just don't know what I'm looking for. I want to tell this client to go find herself a coder to deal with all the little things she brings to me, but I thought maybe it was an easy fix if there was a blip in the code.
 
Old 04-29-2009, 11:41 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
It certainly looks like those blocks do nothing. You can follow the logic yourself

Code:
 if (mail($to, $subject, $body)) 
{ 
#no code here
 } 
else 
{ 
# or here
 } 

 if (mail(trim($_REQUEST['flg5']), $subject, $body)) 
{ 
# or here
 } 
else 
{ 
# or here either ...
 }
reformatted for ease of reading: As you can see nothing happens in the 'to do' blocks..

this could in fact not the production code... certainly I'd hope not...
IMHO, either start learning PHP, might be a handy skill to have and you could get more money by doing all the work, or as you say, tell her to get a programmer...

http://www.php.net/manual/en/ if you're interested.
 
Old 04-30-2009, 12:58 AM   #5
Acron_0248
Member
 
Registered: Feb 2006
Location: Venezuela
Distribution: Gentoo
Posts: 453

Rep: Reputation: 33
Quote:
Originally Posted by picklepie1 View Post
Thanks for your response, Acron. Most of it is Greek to me. I really REALLY don't understand PHP. Are you saying that bit of script can simply be removed without disturbing the rest of the code?
Indeed, even more when the same "test" process is already covered by a previous IF control structure:
PHP Code:
<?php 
$to 
"emailhere@yahoo.com";

# body construction lines here....

if (mail($to$subject$body)) { 
  echo(
"Request Submitted. You will be contacted by one of our staff for appointment confirmation."); 
} else { 
  echo(
"Request Failed. Please try again."); 
}
That IF does indeed something so the other one shouldn't be there, that's why I think that either that script wasn't intended for production or that someone messed it up

Quote:
Originally Posted by picklepie1 View Post
And you don't think the problem lies with this PHP code... the way the code is written, the user should be able to submit their desired reservation day and time? So I should be checking the other html file associated with this file instead, is that right?
The body construction is "ok", could be done better? sure it could, but the point is that there's nothing in the code that explains why 1st and 2nd choices comes blank.

One can assume things as I said earlier but nothing more, so checking other files related to this script will be better.

Quote:
Originally Posted by picklepie1 View Post
I just don't know what I'm looking for. I want to tell this client to go find herself a coder to deal with all the little things she brings to me, but I thought maybe it was an easy fix if there was a blip in the code.
To be honest, the script seems pretty old (unless the use of $_REQUEST is done for compatibility issues) and doesn't have the best practices, it kinda looks like written in a hurry or for someone not very savvy with the language so I agree with chrism01 and with you, it will be better that your client find a coder used to the language or if you want, learn php and take the project in your hands.

Whatever you decide, it might be a simple solution in this case, just a matter of checking other related files to send those emails if you want to try that first



Regards
 
Old 04-30-2009, 02:55 AM   #6
aspire1
Member
 
Registered: Dec 2008
Distribution: Ubuntu
Posts: 62

Rep: Reputation: 23
$i=0;
while (isset($_REQUEST['opt'.$i])) {
$body = $body."Option: ".$_REQUEST['opt'.$i]."\n";
$i++;
}

Stab in the dark here, but the code above looks a bit suspect but I can only guess. Are there fields in the html form whether they be textbox, checkbox or whatever called opt1, opt2 etc. and if so is there one called opt0 ? If they're isn't then that part of $body string won't get built.

I think I've read it wrong, probably ignore this

Last edited by aspire1; 04-30-2009 at 03:01 AM. Reason: Misread
 
Old 04-30-2009, 11:45 AM   #7
Acron_0248
Member
 
Registered: Feb 2006
Location: Venezuela
Distribution: Gentoo
Posts: 453

Rep: Reputation: 33
Quote:
Originally Posted by aspire1 View Post
$i=0;
while (isset($_REQUEST['opt'.$i])) {
$body = $body."Option: ".$_REQUEST['opt'.$i]."\n";
$i++;
}

Stab in the dark here, but the code above looks a bit suspect but I can only guess. Are there fields in the html form whether they be textbox, checkbox or whatever called opt1, opt2 etc. and if so is there one called opt0 ? If they're isn't then that part of $body string won't get built.

I think I've read it wrong, probably ignore this
Indeed, if there is no optX, those statements in the while structure won't be executed, however, that will just avoid adding "Option: something" to the already defined body, meaning that it won't have any effect in 1st and 2nd choices being empty or not
 
Old 04-30-2009, 09:55 PM   #8
picklepie1
LQ Newbie
 
Registered: Apr 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks to everyone for your comments. Yes, I agree that eventually learning PHP will only help me and market my skills to a expanded audience. At this point, the client needs it fixed so I am just going to let her know she needs to direct the problem to a coder.

I appreciate everyone's attention and responses.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php get client's ip through reverse proxy frieza Linux - Networking 2 02-26-2009 11:31 AM
Shell script to remove certain portion of the text kushalkoolwal Programming 4 08-24-2008 11:17 PM
shell script - matching portion of the line alenD Programming 11 10-02-2007 10:22 PM
Getting a client's MAC address from PHP ? michaelsanford Programming 1 05-13-2005 02:10 PM
Size of the client's screen with PHP ??? gluon Programming 2 09-29-2002 04:24 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration