www.webdeveloper.com
Results 1 to 2 of 2

Thread: Cant seem to work out the mail

Hybrid View

  1. #1
    Join Date
    Jan 2014
    Posts
    1

    Cant seem to work out the mail

    Hi everybody

    I am trying to run this script but it throws 500 INTERNAL ERROR PROBLEM though the code doesnot throw any error... I know I am missing something silly... Please help and excuse my ignorance here...

    I am very new!!

    PHP Code:
    <?php
    //output variables

    $output="";

    $host="databasehost.com"// Host name 
    $username="username"// Mysql username 
    $password="password"// Mysql password 
    $db_name="databasename"// Database name 
    $tbl_name="tablename"// Table name 

    // Connect to server and select database.
    mysql_connect("$host""$username""$password")or die("cannot connect"); 
    mysql_select_db("$db_name")or die("cannot select DB");

    $result mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="property-value" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result1 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="firstname" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result2 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="lastname" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result3 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="from_email" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result4 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="houseflat-nos" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result5 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="street" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result6 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="towncity" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result7 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="postcode" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result8 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="telephone" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    $result9 mysql_query('SELECT `field_value` FROM `tablename` WHERE `field_name`="outstanding-mortgage" ORDER BY `submit_time` DESC LIMIT 1') or die('Invalid query: ' mysql_error());

    //print values to screen
    while ($row mysql_fetch_assoc($result)) {
      
    //echo $row['ID'];
      
    $output =  $row['field_value'];
      
    $percentage 75;
      
      
    $prelim = ($percentage 100) * $output;
    }

    while (
    $row mysql_fetch_assoc($result1)) {
      
    //echo $row['ID'];
      
    $output1 =  $row['field_value'];
    }

    while (
    $row mysql_fetch_assoc($result2)) {
      
    //echo $row['ID'];
      
    $output2 =  $row['field_value'];
    }

    while (
    $row mysql_fetch_assoc($result3)) {
      
    //echo $row['ID'];
      
    $output3 =  $row['field_value'];
    }

    while (
    $row mysql_fetch_assoc($result4)) {
      
    //echo $row['ID'];
      
    $output4 =  $row['field_value'];
    }

    while (
    $row mysql_fetch_assoc($result5)) {
      
    //echo $row['ID'];
      
    $output5 =  $row['field_value'];
    }

    while (
    $row mysql_fetch_assoc($result6)) {
      
    //echo $row['ID'];
      
    $output6 =  $row['field_value'];
    }

    while (
    $row mysql_fetch_assoc($result7)) {
      
    //echo $row['ID'];
      
    $output7 =  $row['field_value'];
    }

    while (
    $row mysql_fetch_assoc($result8)) {
      
    //echo $row['ID'];
      
    $output8 =  $row['field_value'];
    }

    while (
    $row mysql_fetch_assoc($result9)) {
      
    //echo $row['ID'];
      
    $output9 =  $row['field_value'];
    }

    // Free the resources associated with the result set
    // This is done automatically at the end of the script
    mysql_free_result($result,$result1,$result2,$result3,$result4,$result5,$result6,$result7,$result8,$result9);

    // References to the name values in your HTML form
    $field_property1 $_POST['typeofproperty'];
    $field_property2 $_POST['bedrooms'];
    $field_property3 $_POST['bathrooms'];
    $field_property4 $_POST['toilets'];
    $field_property5 $_POST['reception'];
    $field_property6 $_POST['garage'];
    $field_property7 $_POST['garden'];
    $field_property8 $_POST['generalCondition'];
    $field_property9 $_POST['builtYear'];
    $field_property10 $_POST['centralHeating'];
    $field_property11 $_POST['doubleGlazing'];
    $field_property12 $_POST['structure'];
    $field_property13 $_POST['association'];
    $field_property14 $_POST['inblock'];
    $field_property15 $_POST['freehold'];
    $field_property16 $_POST['yearsleft'];
    $field_property17 $_POST['why'];
    $field_property18 $_POST['when'];
    $field_property19 $_POST['other'];
    $field_property20 $_POST['how'];
    $field_property21 $_POST['howLong'];
    $field_property22 $_POST['workforproperty'];
    $field_property23 $_POST['uniquefeatures'];
    $field_property24 $_POST['anythingelse'];

    $user "$output3";
    $usersubject "Thank You";
    $userheaders "From: mailsentfrom@email.com\n";
    $usermessage "Thank You for your Enquiry. A member of staff will be in contact shortly to discuss your requirements.";

    // Since some emails are unknown, I reccomend using a known email sender to avoid messages to go directly to the SPAM folder
    $field_sender ' senderemail@email.com';

    // In which address would you like to recieve the messages? Would you like a custom Subject for each?
    $mail_to  ' myemailid@email.com';
    $subject  '[QUALIFIED LEAD] Enuiry ';

    // This builds the message
    $body_message 'From: '.$output1."\n";
    $body_message  .= 'Phone: '.$output8."\n";
    $body_message  .= 'Email: '.$output3."\n\n";
    $body_message  .= 'Flat: '.$output4."\n";
    $body_message  .= 'Street: '.$output5."\n";
    $body_message  .= 'City: '.$output6."\n";
    $body_message  .= 'ZIP: '.$output7."\n\n";
    $body_message  .= 'Property Value: '.$output."\n\n";
    $body_message  .= 'Offer Value: '.$prelim."\n";
    $body_message  .= 'Outstanding Value: '.$output9."\n\n";
    $body_message  .= 'Type of Property: '.$field_property1."\n";
    $body_message  .= 'Number of Bedrooms: '.$field_property2."\n";
    $body_message  .= 'Number of Bathrooms: '.$field_property3."\n";
    $body_message  .= 'Number of Separate Toilets: '.$field_property4."\n";
    $body_message  .= 'Number of Reception Rooms: '.$field_property5."\n";
    $body_message  .= 'Garage: '.$field_property6."\n";
    $body_message  .= 'Garden: '.$field_property7."\n";
    $body_message  .= 'General Condition of Property: '.$field_property8."\n";
    $body_message  .= 'Property Built In: '.$field_property9."\n";
    $body_message  .= 'Central Heating: '.$field_property10."\n";
    $body_message  .= 'Double Glazing: '.$field_property11."\n";
    $body_message  .= 'Structure of Property: '.$field_property12."\n";
    $body_message  .= 'Ex-Council/Housing association: '.$field_property13."\n\n";
    $body_message  .= 'Property in a Block: '.$field_property14."\n";
    $body_message  .= 'Freehold/Leasehold: '.$field_property15."\n";
    $body_message  .= 'Years of Leashold Left: '.$field_property16."\n";
    $body_message  .= 'Reason for Quick Sale: '.$field_property17."\n\n";
    $body_message  .= 'How soon: '.$field_property18."\n\n";
    $body_message  .= 'Any Loans Secured on Property: '.$field_property19."\n\n";
    $body_message  .= 'How Much Loan Secured: '.$field_property20."\n\n";
    $body_message  .= 'Property Currently in Market: '.$field_property21."\n\n";
    $body_message  .= 'For How Long: '.$field_property22."\n\n";
    $body_message  .= 'Any Work Done: '.$field_property23."\n\n";
    $body_message  .= 'Any Unique Feature: '.$field_property24."\n\n";
    $body_message  .= 'Additional Details to Buyer: '.$field_property25."\n\n";


    // Email headers 'From' a known email address to avoid being taken as SPAM and 'Reply-to' the one that filed in the form
    $headers  'From: '.$field_sender."\r\n";
    $headers       .= 'Reply-To: '.$field_email."\r\n";

    // Status, builds whole email structure
    mail($mail_to$subject$body_message$headers);

    mail($user,$usersubject,$usermessage,$userheaders);

    if(
    mail($mail_to$subject$body_message$headers)){
    header("Location: http://websitename.com/thankyou-page/);
    }else{
    header("
    Locationhttp://websitename.com");
    }
    exit;


    ?>

    <?php 
    // close connection 
    mysql_close();
    ?>

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    22,326
    You have a syntax error here: you left out the closing quotes.
    PHP Code:
    header("Location: http://websitename.com/thankyou-page/); 
    PS: A good code editor should have highlighted that for you.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.16567 seconds
  • Memory Usage 3,002KB
  • Queries Executed 13 (?)
More Information
Template Usage (30):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (2)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)showthread_list
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (27):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./includes/functions_threadedmode.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids_threaded
  • showthread_threaded_construct_link
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates