Results 1 to 7 of 7

Thread: [PHP] Parser does not receive data from submit form

  1. #1
    Join Date
    Sep 2014

    [PHP] Parser does not receive data from submit form

    OK, very very strange things going on here...

    I have a contact form on my site and when pushing "Submit", logically the form data gets submitted to the parser which then will upload the data into my MySQL table and also sent out via email.

    Now the weird thing is that the data does not seem to be passed on properly from the form to the parser. Chrome just spits out a regular "No data received error", while IE just times out. Funny enough, the data does get written TWICE into the database, so there definitely is some processing of the parser. Also, this seems to occur randomly since it didnt work in the morning, then worked again in the afternoon, and now in the evening again stopped working.

    * form data is submitted to parser although it often times out and no error pops up
    * MySQL gets the form data written into it several times (At least twice)
    * Email is never sent, which means the process dies before the email is generated, but after the mysql query has been executed

    The form:
    HTML Code:
    <form name="Guest Problem Alert" action="./scripts/GPA/email_parser.php" method="POST">
    							<label for="property">Property:</label><br />
    								<select name="property" style="width: 300px">
    									<option value="DADHA">DADHA</option>
    							<label for="name">Staff name (*):</label><br />
    							<input type="text" name="staff_name" size="30"/>
    // data data data
                                                    <div align="center">
    						<input type="submit" value="Submit" onclick="this.disabled=true; this.value = 'Wait...'; this.form.submit(); return true;" /> <input type='reset' value='Reset'>
    the parser
    PHP Code:

            <title>Guest Problem Alert</title>
            <link rel="shortcut icon" href="./images/favicon.ico">    
            <meta name="viewport" content="width=device-width, user-scalable=no">

    require("../PHPMailer-master/class.phpmailer.php");            // load the PHPmailer script
    date_default_timezone_set('Etc/UTC');                        // set timezone in PHP.ini,required by SMTP
    ini_set('display_errors''On');                            // show all errors
    $edit_url="http://".$_SERVER['HTTP_HOST']."/QCI/scripts/GPA/edit.php";                        // edit.php location and $id value link
    $id uniqid();                                            // Unique ID for identification purposes
    $property $_POST['property'];                         // Property Holidex Code
    $date date("Y-m-d"strtotime('+7 hours'));            // Add 7 hours to date
    $time date("H:i:s"strtotime('+7 hours'));            // Add 7 hours to time
    $staff_name $_POST['staff_name'];                     // required
    $staff_department $_POST['staff_department'];         // not required
    $problem $_POST['problem'];                             // required
    $priority $_POST['priority'];                         // not required
    $gst_name $_POST['gst_name'];                         // not required
    $gst_room $_POST['gst_room'];                         // not required
    $incident $_POST['incident'];                         // required
    $action $_POST['action'];                             // not required
    $followup $_POST['followup'];                         // not required
    $gst_temp $_POST['gst_temp'];                         // not required
    $case_status $_POST['case_status'];                     // required
    $gst_profile $_POST['gst_profile'];                     // not required

    $email_message "<img src='cid:ic_logo' width='400' height='66' alt='IC Logo' /><br/>
        <p>A guest problem alert has been raised for your property, please see details below:</p>
            <tr><td> </td></tr>
            <tr><td>Date & Time</td><td>
    $date - $time</td></tr>
            <tr><td>Staff Name</td><td>
            <tr><td>Staff Department</td><td>
            <tr><td>Guest Name</td><td>
            <tr><td>Guest Room</td><td>
            <tr><td>Follow up</td><td>
            <tr><td>Guest Manner</td><td>
            <tr><td>Case closed?</td><td><b>
            <tr><td>Guest profile updated by:</td><td>
          <p><b>All OPEN CASES must be followed up within 1 hour from now.</b> Please consult with the Resort Assistant Manager on-duty for more details or assistance.<br/>
          <br/><a href=
          Kind regards"

    if ($staff_name == "" OR $problem == "" OR $incident == "" OR $case_status == ""
    "<img src=\"../../images/iclogo_small.jpg\" style=\"width: 300px\"><br/><font size=\"3\"><b><u>ERROR</u></b><br/></font>
            You did not enter a valid Staff Name, Guest Problem, Incident Message or Case Status.<br/><br/>Please <a href=\"javascript:history.go(-1)\">[Go Back]</a> and fix this.<br/><br />
            <input action=\"action\" type=\"button\" value=\"Back\" onclick=\"history.go(-1);\" />"

    if    (    isset($staff_name) && isset($problem) && isset($incident) && isset($case_status)    )
    $data $property '|' $id '|' $date '|' $time '|' $staff_name '|' $staff_department '|' $problem '|' $priority '|' $gst_name '|' $gst_room '|' $incident '|' $action '|' $followup '|' $gst_temp '|' $case_status '|' $gst_profile "\n";
    $ret file_put_contents('GPAdata.txt'$dataFILE_APPEND LOCK_EX);
                        if    (
    $ret === false)    
    'There was an error writing this file');
    mysql_connect("host""user""password") or die(mysql_error());
    mysql_select_db("b24_15096338_GPA") or die(mysql_error());
    mysql_query("INSERT INTO `GPA` VALUES ('$id','$property','$date','$time','$staff_name','$staff_department','$problem','$priority','$gst_name','$gst_room','$incident','$action','$followup','$gst_temp','$case_status','$gst_profile')");
    $mail = new PHPMailer();
    $mail->isSMTP();                                                // Set connection type to SMTP
    $mail->SMTPDebug 0;                                            // Enable SMTP debugging, 0 = off (for production use), 1 = client messages, 2 = client and server messages
    $mail->Debugoutput 'html';                                    // Set the output format for SMTP Debug
    $mail->Host "mail.host.com";                                    // Mail Host Server
    $mail->Port 25;                                                // SMTP Port (usually 25)
    $mail->SMTPAuth true;                                            // Authentication needed? true/false
    $mail->Username " mail@mail.com";                                // Login Username
    $mail->Password "pw";                                            // Login Password
    $mail->setFrom('mail@mail.com');                                // Sent FROM
    $mail->addReplyTo('mymail@mail.com');                            // Add REPLY-TO address
    $mail->addAddress('someones@mail.com');                            // Send TO

    $mail->Subject $property ' - Guest Problem Alert';
    $mail->Body $email_message;
    $mail->isHTML(TRUE);                                            // HTML body? true/false
    //$mail->msgHTML("<table><tr><th>cat1</th><th>cat2</th></tr><td>Date & Time</td><td>".$time_GMT11."</td></table>");                                // Message body - HTML
            //$mail->body = $email_message;                                    // Message body - regular
            //$mail->AltBody = $email_message;                                // Message body - plain text
            //$mail->addAttachment('../../images/iclogo_small.jpg');        // Attachment if necessary
            //send the message, check for errors
    if (!$mail->send()) 
    "Mailer Error: " $mail->ErrorInfo;
            else    {
    "<img src=\"../../images/iclogo_small.jpg\" style=\"width: 300px\"><br/><font size=\"3\"><b><u>MESSAGE SENT!</u></b><br/></font>
                            Thank you very much for submitting the Guest Problem Alert. <br><br>All OPEN CASES must be follow up within 1 hour, please consult with the Resort Assistant Manager on-duty for further follow up.<br/>
                            <input action=\"action\" type=\"button\" value=\"Back\" onclick=\"history.go(-1);\" />"
    No idea, really. It used to work fine before, just since this morning that I have all these issues. Can this be my host? Since the script seem to die in the middle of parsing, maybe a connectivity issue?

    Thanks for any suggestions,
    Last edited by NogDog; 09-15-2014 at 01:33 PM. Reason: changed [code] tags to [php]

  2. #2
    Join Date
    Jul 2013
    Voorheesville NY USA
    What is this parser you speak of?

    And how are the two blocks of code you provided tied together?
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

  3. #3
    Join Date
    Aug 2004
    I see nothing obvious that would cause a submit to update the DB twice, though I might be tempted to remove the onclick event from your submit tag just to see if that has any bearing on things. (If you have JavaScript do the submit, then return true, does the form submit itself again?)
    "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

  4. #4
    Join Date
    Jul 2013
    Voorheesville NY USA
    Two things I don't like.

    1 - you don't check the results of your query call. Do so to be sure it actually ran.
    2 - this code is not standard
    PHP Code:
    <a href=$edit_url?id=$id
    the attributes of this statement should be in quotes:
    PHP Code:
    <a href="$edit_url?id=$id"
    And - IMHO - a text file is In No Way a database. Please stop referring to it as one. Maintaining your data in two distinct formats is really kind of silly. Write yourself a simple 'dump' script that will produce a text-only document from your true database when you need one.

    And what's up with the formatting of your post? Very hard to read.

    And - It's time to update your html knowledge and stop using ancient tags and styling. No more <font> tags.

    And make your life easier by using both double and single quotes so you don't have to keep escaping them in your code.

    And - add this to your code:
    error_reporting(E_ALL | E_NOTICE);
    before you turn on display_errors.
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

  5. #5
    Join Date
    Sep 2014
    haha, well, thanks for all the complaints

    My HTML is indeed ancient as all of this is based on what I learned maybe 10-12 years ago when HTML4 was the talk of the block, guess I do have to freshen up.

    Alright, lets wrap this up:
    <a href=$edit_url?id=$id>
    is currently in there only for testing purposes, has no actual use yet

    2. I did remove the onclick procedure before but have no different result. I didnt try to change the submit to TRUE, will see what happens
    3. I am writing into a textfile first because I would like to have a backup on my local server, but naturally am primarily using my MySQL database
    4. I have E_ALL on top already but do not receive any error message

    Funny enough, the script was running well again this morning. Unless anyone else here suggests otherwise, I would say its time for me to find another webhost.... Any suggestions on free webhosts that have MySQL and PHP5 with min. 20mb space?


  6. #6
    Join Date
    Jul 2013
    Voorheesville NY USA
    Free webhosts? Remember - you get what you pay for. Ads.

    I am very happy with my host - been with them for 10+ years. Had one daylong downtime I think. Good response when seeking TS help. Biggest plan less than $100 a year. 123ehost.com
    PS - If you're posting here you should be using:

    ini_set('display_errors', '1');

    at the top of ALL php code while you develop it!

  7. #7
    Quote Originally Posted by NogDog View Post
    (If you have JavaScript do the submit, then return true, does the form submit itself again?)
    We have a winner. That should be EXACTLY what's going on... and why relying on scripttardery to prevent double submit is silly nonsense.

    Instead of that garbage I'd put in a input[hidden] with a unique random hash on it; store the hash in sessions server side and compare on submit, no match it must be a mistake.

    Of course it would be a lot easier to figure out what was going on if the markup was dragged kicking and screaming out of the late '90's browser wars, what with tags and attributes like FONT and ALIGN that have no business in any code written after 1997; likewise this is 2014 not 2006, why are you still using the mysql_ functions that we've been told to stop using since PHP 5 dropped and that they've now added GIANT RED WARNING BOXES to the manual waving you off from it's use?

    The bizarroland willy-nilly formatting isn't helping matters either.

Thread Information

Users Browsing this Thread

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

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.14922 seconds
  • Memory Usage 3,011KB
  • Queries Executed 15 (?)
More Information
Template Usage (36):
  • (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
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)bbcode_html
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./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
  • ./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 (70):
  • 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
  • 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_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