Jump to content

Just starting in php


kevinrea

Recommended Posts

hi guys,

i am just starting in php.

i am trying to get my swish form to work, when i click the submit, it just says "WAITING FOR BLAH BLAH BLAH WEBSITE" at the bottom of the browser window.. it never really seems to send.

my website supports it,.. i am using it in conjunction with a swish form that i made.

here is the code behind the submit button on my swish form..

**********************************

on (press) {

    Name = ClientName.text;

    ClntEmail = Email.text;

    ClntAddress = Address.text;

    ClntCity = ClientCity.text;

    ClntState = ClientState.text;

    ClntZipcode = ClientZipcode.text;

    PropType = PropertyType.text;

    DesCity = DesiredCity.text;

    PriceRnge = PriceRange.text;

    MinBdrooms = MinimumBedrooms.text;

    MinBthrooms = MinimumBathrooms.text;

    MinSqFt = MinimumSquareFootage.text;

    MinLotSze = MinLotSizeAcreage.text;

    TypeConst = TypeOfConstruction.text;

    AddComments = AdditionalComments.text;

    loadVariables("contact.php",'POST');

***********************************

 

and then , here is the content of my .php file which is called  'contact.php', and it transferred to the

website using ASCII, so it wouldn't corrupt it as a binary transfer seems to do....

 

**************************************

<?php

 

$Name = $HTTP_POST_VARS['Name'];

$Email = $HTTP_POST_VARS['ClntEmail'];

$Address = $HTTP_POST_VARS['ClntAddress'];

$City = $HTTP_POST_VARS['ClntCity'];

$State = $HTTP_POST_VARS['ClntState'];

$Zipcode = $HTTP_POST_VARS['ClntZipcode'];

$PropertyType = $HTTP_POST_VARS['PropType'];

$DesiredCity = $HTTP_POST_VARS['DesCity'];

$PriceRange = $HTTP_POST_VARS['PriceRnge'];

$MinBedrooms = $HTTP_POST_VARS['MinBdrooms']

$MinBathrooms = $HTTP_POST_VARS['MinBthrooms'];

$MinSqFoot = $HTTP_POST_VARS['MinSqFt'];

$MinLotSize = $HTTP_POST_VARS['MinLotSze'];

$AdditionalComments = $HTTP_POST_VARS['AddComments'];

 

$message = stripslashes($AddComments);

 

$sendTo = "ksrea@sbcglobal.net";

$subject = "Message from Contact Form on SearchWestervilleHomes.com";

 

$msg_body = "Name: $name\n";

$msg_body .= "E-Mail: $email\n";

$msg_body .= "Address: $address\n";

$msg_body .= "City: $City\n";

$msg_body .= "State: $State\n";

$msg_body .= "Zipcode: $Zipcode\n";

 

$msg_body .= "Property Type: $PropertyType\n";

$msg_body .= "Desired City-Area: $DesiredCity\n";

$msg_body .= "Price Range: $PriceRange\n"

$msg_body .= "Minimum Bedrooms: $MinBedrooms\n";

$msg_body .= "Minimum Bathrooms: $MinBathrooms\n";

$msg_body .= "Minimum Square Feet: $MinSqFoot\n";

$msg_body .= "Minimum Lot Size/Acreage: $MinLotSize\n";

$msg_body .= "Additional Comments: $AdditionalComments\n";

 

 

$header_info = "From: ".$name." <".$email.">";

 

mail($sendTo, $subject, $msg_body, $header_info);

 

?>

****************************

 

any help would be appreciated.

 

Kevin

 

 

Link to comment
Share on other sites

Firstly, I'm not sure where your learning php from but the $HTTP_POST_VARS[] array has long been depricated in favour of $_POST[]. Secondly, you'll need to check the form was submitted to the page before attempting to assign values to variables from the $_POST[] array. Thirdly, you'll want to wrap your call to the mail() function in a conditional to see if it has succeeded. Try...

 

<?php

if (isset(_POST['Name'])) {
  $Name = $_POST['Name'];
  $Email = $_POST['ClntEmail'];
  $Address = $_POST['ClntAddress'];
  $City = $_POST['ClntCity'];
  $State = $_POST['ClntState'];
  $Zipcode = $_POST['ClntZipcode'];
  $PropertyType = $_POST['PropType'];
  $DesiredCity = $_POST['DesCity'];
  $PriceRange = $_POST['PriceRnge'];
  $MinBedrooms = $_POST['MinBdrooms']
  $MinBathrooms = $_POST['MinBthrooms'];
  $MinSqFoot = $_POST['MinSqFt'];
  $MinLotSize = $_POST['MinLotSze'];
  $AdditionalComments = $_POST['AddComments'];

  $message = stripslashes($AddComments);

  $sendTo = "ksrea@sbcglobal.net";
  $subject = "Message from Contact Form on SearchWestervilleHomes.com";

  $msg_body = "Name: $name\n";
  $msg_body .= "E-Mail: $email\n";
  $msg_body .= "Address: $address\n";
  $msg_body .= "City: $City\n";
  $msg_body .= "State: $State\n";
  $msg_body .= "Zipcode: $Zipcode\n";
  $msg_body .= "Property Type: $PropertyType\n";
  $msg_body .= "Desired City-Area: $DesiredCity\n";
  $msg_body .= "Price Range: $PriceRange\n"
  $msg_body .= "Minimum Bedrooms: $MinBedrooms\n";
  $msg_body .= "Minimum Bathrooms: $MinBathrooms\n";
  $msg_body .= "Minimum Square Feet: $MinSqFoot\n";
  $msg_body .= "Minimum Lot Size/Acreage: $MinLotSize\n";
  $msg_body .= "Additional Comments: $AdditionalComments\n";

  $header_info = "From: ".$name." <".$email.">";

  if (mail($sendTo, $subject, $msg_body, $header_info)) {
    echo "Success";
  } else {
    echo "Failed to send mail";
  }

}

?>

 

Post the results.

Link to comment
Share on other sites

HI Thorpe,

 

thanks for the help.

I got the php from being referenced there from some of the folks on the swishzone forum., to this page...

http://www.swishzone.com/index.php?area=resources&tab=tutorials&do=page&action=detailed&link_id=152

 

also, what file sharing properties should the php file have on the server ??? shold it be 0777 ?\

is there any way to check a php script to see if it is really working other than putting it up on the website ?

 

kevin

Link to comment
Share on other sites

also, what file sharing properties should the php file have on the server  shold it be 0777 ?

 

The term is "permissions" and they should be 0755.

 

is there any way to check a php script to see if it is really working other than putting it up on the website ?

 

Not easily. You should develop locally and/or a different location than the live site.

Link to comment
Share on other sites

you can detect syntactical errors very easily if you have a pretty print editor as if you have quoted issues, missing semi colon etc it will not color the lines down further.  If you aren't using a line number/pretty print editor I suggest you will, it will save you and us lots of time diagnosing silly problems.

Link to comment
Share on other sites

hi thorpe,

thanks for your help.

i installed  web server locally, it is Easy file Sharing Web Server, and i put the pages up there and when i click on the submit button, in the log it says " Post/serverdirectory/contact.php.,

so, does that mean it is working ok ?

 

thanks,

kevin

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.