I did a test and this is what my php error log shows on hostinger with php version 8.2
[01-Aug-2023 ] PHP Warning: Undefined variable $upload_FieldName in /home/domains/mywebsite.com/public_html/index.php on line 229
[01-Aug-2023 ] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/domains/mywebsite.com/public_html/index.php:229
Stack trace:
#0 {main}
thrown in /home/domains/mywebsite.com/public_html/index.php on line 229
[01-Aug-2023 ] PHP Warning: Undefined variable $upload_FieldName in /home/domains/mywebsite.com/public_html/index.php on line 229
[01-Aug-2023 ] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /home/domains/mywebsite.com/public_html/index.php:229
Stack trace:
#0 {main}
thrown in /home/domains/mywebsite.com/public_html/index.php on line 229
[01-Aug-2023 13:53:47 UTC] PHP Fatal error: Uncaught mysqli_sql_exception: Duplicate column name 'FORMID' in /home/domains/mywebsite.com/public_html/index.php:242
Stack trace:
#0 /home/domains/mywebsite.com/public_html/index.php(242): mysqli_query()
#1 {main}
thrown in /home/domains/mywebsite.com/public_html/index.php on line 242
and below is the code which it was referring to which I think is the php script for the form.
$mail->CharSet = 'UTF-8';
$mail->WordWrap = 80;
$mail->Body = $message;
$mail->Send();
$search = array("ä", "Ä", "ö", "Ö", "ü", "Ü", "ß", "!", "§", "$", "%", "&", "/", "\x00", "^", "°", "\x1a", "-", "\"", " ", "\\", "\0", "\x0B", "\t", "\n", "\r", "(", ")", "=", "?", "`", "*", "'", ":", ";", ">", "<", "{", "}", "[", "]", "~", "²", "³", "~", "µ", "@", "|", "<", "+", "#", ".", "´", "+", ",");
$replace = array("ae", "Ae", "oe", "Oe", "ue", "Ue", "ss");
foreach($_POST as $name=>$value)
{
$name = str_replace($search, $replace, $name);
$name = strtoupper($name);
if (is_array($value))
{
$form_data[$name] = implode(",", $value);
}
else
{
$form_data[$name] = $value;
}
}
#229 for ($i = 0; $i < count($upload_FieldName); $i++)
{
$name = str_replace($search, $replace, $upload_FieldName[$i]);
$name = strtoupper($name);
$form_data[$name] = $upload_URL[$i];
}
$db = mysqli_connect($mysql_server, $mysql_username, $mysql_password) or die('Failed to connect to database server!<br>'.mysqli_error($db));
mysqli_set_charset($db, 'utf8');
mysqli_query($db, "CREATE DATABASE IF NOT EXISTS $mysql_database");
mysqli_select_db($db, $mysql_database) or die('Failed to select database<br>'.mysqli_error($db));
mysqli_query($db, "CREATE TABLE IF NOT EXISTS $mysql_table (ID int(9) NOT NULL auto_increment, `DATESTAMP` DATE, `TIME` VARCHAR(8), `IP` VARCHAR(15), `BROWSER` TINYTEXT, PRIMARY KEY (id))");
foreach($form_data as $name=>$value)
{
#242 mysqli_query($db ,"ALTER TABLE $mysql_table ADD $name VARCHAR(255)");
}
mysqli_query($db, "INSERT INTO $mysql_table (`DATESTAMP`, `TIME`, `IP`, `BROWSER`)
VALUES ('".date("Y-m-d")."',
'".date("G:i:s")."',
'".$_SERVER['REMOTE_ADDR']."',
'".$_SERVER['HTTP_USER_AGENT']."')")or die('Failed to insert data into table!<br>'.mysqli_error($db));
$id = mysqli_insert_id($db);
foreach($form_data as $name=>$value)
{
mysqli_query($db, "UPDATE $mysql_table SET $name='".mysqli_real_escape_string($db, $value)."' WHERE ID=$id") or die('Failed to update table!<br>'.mysqli_error($db));
}
mysqli_close($db);
$successcode = file_get_contents($success_url);
$successcode = ReplaceVariables($successcode);
echo $successcode;
}
catch (Exception $e)
{
$errorcode = file_get_contents($error_url);
$replace = "##error##";
$errorcode = str_replace($replace, $e->getMessage(), $errorcode);
echo $errorcode;
}
exit;
}
?>
Email form not working on new server
Forum rules
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/forms.html
http://www.wysiwygwebbuilder.com/form_wizard.html
Frequently Asked Questions about Forms
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901
MUST READ:
http://www.wysiwygwebbuilder.com/forms.html
http://www.wysiwygwebbuilder.com/form_wizard.html
Frequently Asked Questions about Forms
- wwonderfull
-
- Posts: 1586
- Joined: Fri Aug 21, 2020 8:27 am
- Contact:
Re: Email form not working on new server
Last edited by wwonderfull on Wed Aug 02, 2023 10:23 am, edited 2 times in total.
Re: Email form not working on new server
@wwonderfull
Thanks for trying to help. However, this is has nothing to do with sending emails.
This is because you have enabled 'upload files to a folder on the server'.
To test this correctly, please disable all advanced options in the form and only configure it to send emails. Otherwise your feedback may only cause further confusion...
Thanks for trying to help. However, this is has nothing to do with sending emails.
This is because you have enabled 'upload files to a folder on the server'.
To test this correctly, please disable all advanced options in the form and only configure it to send emails. Otherwise your feedback may only cause further confusion...
- wwonderfull
-
- Posts: 1586
- Joined: Fri Aug 21, 2020 8:27 am
- Contact:
Re: Email form not working on new server
PHP version 8.2 HostingerPablo wrote: Tue Aug 01, 2023 2:29 pm @wwonderfull
Thanks for trying to help. However, this is has nothing to do with sending emails.
This is because you have enabled 'upload files to a folder on the server'.
To test this correctly, please disable all advanced options in the form and only configure it to send emails. Otherwise your feedback may only cause further confusion...
The form works fine only when the form's advanced options are all turned off like mysql settings specially. The success page shows too. I even used attachments which also came in email without any error.
Only when I turned on the mysql option in the forms advanced option it showed this error.
Fatal error: Uncaught mysqli_sql_exception: Duplicate column name 'FORMID'
PHP 7.3 and 7.4 everything works fine in hostinger but only when it is above 8 those errors happen.
Re: Email form not working on new server
Thank you for all your replys.
It is nice to know someone else has experienced these problems. I think you are right it is PHP8 and above that causes the error with the successful page showing.
I will continue to investigate this and when I have found the solution I will come back and share. Thank you for all your help
All the best Andrew
It is nice to know someone else has experienced these problems. I think you are right it is PHP8 and above that causes the error with the successful page showing.
I will continue to investigate this and when I have found the solution I will come back and share. Thank you for all your help
All the best Andrew
Re: Email form not working on new server
@AndySwiny
Please note that error shown in wwonderfull's test may not apply to you because he's using a different form configuration
I do not think these error are related. Also, as you can read the basic form works correct. So, it can also work for you.
First, make sure that you upload all files. The files that are include with WWB18 are the latest! See my previous replies.
Then check the PHP error log for other error (if any).
@wwonderfull
Please focus on the main issue. You may make it more confusing for Andy. These database errors are unrelated. There is most likely an error in your configuration. If you need help with this then open a new topic.
Please note that error shown in wwonderfull's test may not apply to you because he's using a different form configuration
I do not think these error are related. Also, as you can read the basic form works correct. So, it can also work for you.
First, make sure that you upload all files. The files that are include with WWB18 are the latest! See my previous replies.
Then check the PHP error log for other error (if any).
@wwonderfull
Please focus on the main issue. You may make it more confusing for Andy. These database errors are unrelated. There is most likely an error in your configuration. If you need help with this then open a new topic.
Re: Email form not working on new server
I now have my forms/emails working
Hi if you are having problems this is where to start and how to try and solve it
Start with three new pages
one page extension PHP
2 pages with HTML
Make sure you name each page correctly go to the advanced tab and set
jquery version 3.6.9 min.js
PHP version PHP5 - PHP8
Everything else remains the same default
For this I will name my pages
My form the PHP page
sent-ok HTML
not-sent HTML
on the PHP page put from on here you can use the wizard or not
go to form settings this is what I used
Name the form whatever you wish
Accept charset = ISO-8859-1
Target _top
Tick the box use built-in PHP
Put your Email in
set successful page to sent_ok HTML
set error page to not_sent HTML
Go to the advanced tab on their go to mail engine tab
Tick the box and set mail engine = ( Sendmail) everything else default
For now on your successful page just put a bit of text sent okay
on the error page just part not sent
now load all three files when you upload the PHP file it will upload three other files as well
Exception.php
PHPMailer.php
SMTP.php
Make sure these files are in the same directory as the form
Now go to the website fill in the form and see if it works this worked for me I hope it works for you
All the best Andrew
Hi if you are having problems this is where to start and how to try and solve it
Start with three new pages
one page extension PHP
2 pages with HTML
Make sure you name each page correctly go to the advanced tab and set
jquery version 3.6.9 min.js
PHP version PHP5 - PHP8
Everything else remains the same default
For this I will name my pages
My form the PHP page
sent-ok HTML
not-sent HTML
on the PHP page put from on here you can use the wizard or not
go to form settings this is what I used
Name the form whatever you wish
Accept charset = ISO-8859-1
Target _top
Tick the box use built-in PHP
Put your Email in
set successful page to sent_ok HTML
set error page to not_sent HTML
Go to the advanced tab on their go to mail engine tab
Tick the box and set mail engine = ( Sendmail) everything else default
For now on your successful page just put a bit of text sent okay
on the error page just part not sent
now load all three files when you upload the PHP file it will upload three other files as well
Exception.php
PHPMailer.php
SMTP.php
Make sure these files are in the same directory as the form
Now go to the website fill in the form and see if it works this worked for me I hope it works for you
All the best Andrew
Re: Email form not working on new server
Andrew
Just a note of thanks as I have been having similar problems with Hostinger and had no success in resolving with their chat support. With my previous host I used SMTP successfully but on transferring to Hostinger 3 weeks ago, the emails generated via a form had been erratic. Your simple solution of using "sendmail" has worked for me, so I am very grateful. Now all I have to do is to sort out why MySQL scripts are not performing as they used to!
Brian
Just a note of thanks as I have been having similar problems with Hostinger and had no success in resolving with their chat support. With my previous host I used SMTP successfully but on transferring to Hostinger 3 weeks ago, the emails generated via a form had been erratic. Your simple solution of using "sendmail" has worked for me, so I am very grateful. Now all I have to do is to sort out why MySQL scripts are not performing as they used to!
Brian
- wwonderfull
-
- Posts: 1586
- Joined: Fri Aug 21, 2020 8:27 am
- Contact:
Re: Email form not working on new server
Just in case if anyone wanted to know about the form not working on higher php versions. The problem I stated has been fixed and solved in the latest update 18.3.2.