This topic is locked
[SOLVED]

 Submit button on add record not working intermittently

12/3/2019 1:09:19 PM
PHPRunner General questions
B
bcritchley author

Update 12/05/2019 : I can't remember/find the line of code I would need to add to my script to show the error(s) that might be getting received on the screen, can someone point me in the right direction to add that line of code back in?
I have a version 10.3 project that lets customers submit a courier request and the data resides in a MSSQL server database. The customer goes directly to an add page that they fill out 8 required fields, and 2 optional fields and then they hit submit. On the events page for the add Page, I have an "JavaScript onload event" that sets the tab order and also sets the max length of one of the fields to 500 characters.
$("input[id^='value_Requestor_Name']").attr('tabindex', 1);

$("input[id^='value_Requestor_Email']").attr('tabindex', 2);

$("input[id^='value_Requestor_Phone']").attr('tabindex', 3);

$("select[id^='value_Pickup_Location']").attr('tabindex', 4);

$("select[id^='value_Destination_Location']").attr('tabindex', 5);

$("input[id^='value_Earliest_Pickup_Date']").attr('tabindex', 6);

$("input[id^='value_Latest_Pickup_Date']").attr('tabindex', 7);

$("input[id^='value_Item_Weight']").attr('tabindex', 8);

$("input[id^='value_Item_Size']").attr('tabindex', 9);

$("textarea[id^='value_Details']").attr('tabindex', 10);
var ctrlDetails = Runner.getControl(pageid,'Details');
ctrlDetails.on('keyup',function(e, argsArr){

var len = this.getValue().length;

if (len > 500)

{

alert("Maximum length allowed: 500.");

this.setValue(this.getValue().substring(0, 500));

}

});
I also have an After record added script that sends an email and notifies the user that their request was successful.
//** Send email with new data ****
$email=$values['Requestor_Email'];

$from="central.stores@greececsd.org";

$msg="Thank you for using the electronic courier request submission form. We have received your request and will expedite promptly. The details of your request are in the email below"."\r\n\n";

$subject="Your New Electronic Courier Request";
$msg.= "Name: ".$values['Requestor_Name']."\r\n";

$msg.= "Email: ".$values['Requestor_Email']."\r\n";

$msg.= "Request Number: ".$values['Request_Number']."\r\n";

$msg.= "Date needed: ".$values['Latest_Pickup_Date']."\r\n";

$msg.= "Pickup from: ".$values['Pickup_Location']."\r\n";

$msg.= "Deliver to: ".$values['Destination_Location']."\r\n";

$msg.= "Request: ".$values['Details']."\r\n";
$ret=runner_mail(array('to' => $email, 'bcc' => 'central.stores@greececsd.org', 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
echo "<script>alert('Thank you for using the Courier Request System, your request number is: ".$values['Request_Number']."')</script>";
I have some users that when they click the submit button, the screen refreshes, but they do not get the successful request message. The database in the background increases the next available PK field by one, but no record is added to the database.

M
Mark Kramer 12/11/2019



Update 12/05/2019 : I can't remember/find the line of code I would need to add to my script to show the error(s) that might be getting received on the screen, can someone point me in the right direction to add that line of code back in?
I have a version 10.3 project that lets customers submit a courier request and the data resides in a MSSQL server database. The customer goes directly to an add page that they fill out 8 required fields, and 2 optional fields and then they hit submit. On the events page for the add Page, I have an "JavaScript onload event" that sets the tab order and also sets the max length of one of the fields to 500 characters.
$("input[id^='value_Requestor_Name']").attr('tabindex', 1);

$("input[id^='value_Requestor_Email']").attr('tabindex', 2);

$("input[id^='value_Requestor_Phone']").attr('tabindex', 3);

$("select[id^='value_Pickup_Location']").attr('tabindex', 4);

$("select[id^='value_Destination_Location']").attr('tabindex', 5);

$("input[id^='value_Earliest_Pickup_Date']").attr('tabindex', 6);

$("input[id^='value_Latest_Pickup_Date']").attr('tabindex', 7);

$("input[id^='value_Item_Weight']").attr('tabindex', 8);

$("input[id^='value_Item_Size']").attr('tabindex', 9);

$("textarea[id^='value_Details']").attr('tabindex', 10);
var ctrlDetails = Runner.getControl(pageid,'Details');
ctrlDetails.on('keyup',function(e, argsArr){

var len = this.getValue().length;

if (len > 500)

{

alert("Maximum length allowed: 500.");

this.setValue(this.getValue().substring(0, 500));

}

});
I also have an After record added script that sends an email and notifies the user that their request was successful.
//** Send email with new data ****
$email=$values['Requestor_Email'];

$from="central.stores@greececsd.org";

$msg="Thank you for using the electronic courier request submission form. We have received your request and will expedite promptly. The details of your request are in the email below"."\r\n\n";

$subject="Your New Electronic Courier Request";
$msg.= "Name: ".$values['Requestor_Name']."\r\n";

$msg.= "Email: ".$values['Requestor_Email']."\r\n";

$msg.= "Request Number: ".$values['Request_Number']."\r\n";

$msg.= "Date needed: ".$values['Latest_Pickup_Date']."\r\n";

$msg.= "Pickup from: ".$values['Pickup_Location']."\r\n";

$msg.= "Deliver to: ".$values['Destination_Location']."\r\n";

$msg.= "Request: ".$values['Details']."\r\n";
$ret=runner_mail(array('to' => $email, 'bcc' => 'central.stores@greececsd.org', 'subject' => $subject, 'body' => $msg, 'from'=>$from));

if(!$ret["mailed"])

echo $ret["message"];
echo "<script>alert('Thank you for using the Courier Request System, your request number is: ".$values['Request_Number']."')</script>";
I have some users that when they click the submit button, the screen refreshes, but they do not get the successful request message. The database in the background increases the next available PK field by one, but no record is added to the database.


Are they using the same browser?

lefty 12/11/2019



Are they using the same browser?


Quote : "
If the record is not added to database , then it is happening in the before add event not after add ( with your example ) . Can you show the code in before record added? That will help. Like PK field code?

When you say some , does that mean sometimes the record adds and gives message or the record never adds and sometimes gives the message?

As far as refreshing I don't see any code that you have above to refresh the page? // As if you try refresh after record added and redirect - therefore no message

And finally are the emails being sent with values as it should never get to that if the syntax is incorrect in before add?

Without seeing all the code ; I would take out the Javascript temporarily and test? Or use Debugging JS to make sure that is not causing any issues.
This may be off the topic discussed above but I want to add the below to your previous post on October 11th 2019.
I also see a potential problem depending on your server you use to send emails . If you use in email settings ( email field in PHPrunner smtp settings ) a different email from the $from field in your code (if not the same domain) , that surely on most servers will cause issues 1. may go to junk folder on users side 2. may not be accepted at destination (x-spam status poor ) . 3. may get blacklisted. " I have had this happen and learned the hard way as I then had to have the company whitelist my domain to get the emails in inbox instead of spam/junk/clutter". MSN.com email won't even accept the email ( if I don't use the same $from email as setup in email settings on PHPrunner) as I have tested thoroughly in the past as an example..... etc. .) So when testing emails ,for email try first to echo or print success on page - message to page for debugging purposes and if successful and you don't see email in any inboxes, then you know my above explanation above is causing the issue.
Hope this helps !

B
bcritchley author 12/26/2019

Thank you for the info John, and I have since gotten the email server and send from address in sync.

I have also figured out what was causing my original issue. I had a value list for 2 of my fields and the values contained the "&" ampersand character. When someone was choosing that as there drop down value, the SQL database was not allowing the value to be input. Once I renamed my values to not include the special characters, all seems good.



Quote : "
If the record is not added to database , then it is happening in the before add event not after add ( with your example ) . Can you show the code in before record added? That will help. Like PK field code?

When you say some , does that mean sometimes the record adds and gives message or the record never adds and sometimes gives the message?

As far as refreshing I don't see any code that you have above to refresh the page? // As if you try refresh after record added and redirect - therefore no message

And finally are the emails being sent with values as it should never get to that if the syntax is incorrect in before add?

Without seeing all the code ; I would take out the Javascript temporarily and test? Or use Debugging JS to make sure that is not causing any issues.
This may be off the topic discussed above but I want to add the below to your previous post on October 11th 2019.
I also see a potential problem depending on your server you use to send emails . If you use in email settings ( email field in PHPrunner smtp settings ) a different email from the $from field in your code (if not the same domain) , that surely on most servers will cause issues 1. may go to junk folder on users side 2. may not be accepted at destination (x-spam status poor ) . 3. may get blacklisted. " I have had this happen and learned the hard way as I then had to have the company whitelist my domain to get the emails in inbox instead of spam/junk/clutter". MSN.com email won't even accept the email ( if I don't use the same $from email as setup in email settings on PHPrunner) as I have tested thoroughly in the past as an example..... etc. .) So when testing emails ,for email try first to echo or print success on page - message to page for debugging purposes and if successful and you don't see email in any inboxes, then you know my above explanation above is causing the issue.
Hope this helps !