-3

LIVE SAMPLE this is my sample live website

The Problem is my code for a "Contact-Us" works fine when i use it offline(wampserver) but when i upload it to my cpanel it doesnt work... i tried almost everything but the alert just sends me the "connection failed" the Connection.php works fine i can connect to the database, the problem seems to be in the INSERT statement. i don't see any problems in my code, because my other "registration" form works just fine online see my sample website. there's no error problem on my code because i already cheked the error log:

the image is my error logs on my online web. doesnt have problems in it..

    <?php 

include_once 'Connection.php';

if(isset($_POST['btn-index']))
{
 $first_name = $_POST['first_name'];
 $email = $_POST['email'];
 $contact = $_POST['contact'];
 $subject = $_POST['subject'];
 $message = $_POST['workarea'];


$first_name = stripslashes($_REQUEST['first_name']);
$first_name = mysqli_real_escape_string($conn,$first_name);

$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($conn,$email);

$contact = stripslashes($_REQUEST['contact']);
$contact = mysqli_real_escape_string($conn,$contact);

$subject = stripslashes($_REQUEST['subject']);
$subject = mysqli_real_escape_string($conn,$subject);

$message = stripslashes($_REQUEST['workarea']);
$message = mysqli_real_escape_string($conn,$message);

$sql = "INSERT INTO `inquiry` (First_Name,Email,Contact,Subj,Message)
VALUES('$first_name','$email','$contact','$subject','$message')";

if($conn->query($sql) === TRUE)
        {
            ?>
            <script>
            alert('Records Submitted!');
            window.location.href='index.php#parent_contacts';
            </script>
            <?php
        }
        else
        {
            ?>
            <script>
            alert('Connection Failed...');
            window.location.href='index.php#parent_contacts';
            </script>
            <?php
        }
$conn->close();
}

//---------FOR ABOUT-US.PHP-------------------------
if(isset($_POST['btn-contact']))
{
 $name = $_POST['name'];
 $email = $_POST['email'];
 $contact = $_POST['contact'];
 $subject = $_POST['subject'];
 $message = $_POST['message'];


$name = stripslashes($_REQUEST['name']);
$name = mysqli_real_escape_string($conn,$name);

$email = stripslashes($_REQUEST['email']);
$email = mysqli_real_escape_string($conn,$email);

$contact = stripslashes($_REQUEST['contact']);
$contact = mysqli_real_escape_string($conn,$contact);

$subject = stripslashes($_REQUEST['subject']);
$subject = mysqli_real_escape_string($conn,$subject);

$message = stripslashes($_REQUEST['message']);
$message = mysqli_real_escape_string($conn,$message);

$sql = "INSERT INTO `inquiry` (First_Name,Email,Contact,Subj,Message)
VALUES('$name','$email','$contact','$subject','$message')";

if($conn->query($sql) === TRUE)
        {
            ?>
            <script>
            alert('Records Submitted!');
            window.location.href='Contact-Us.php';
            </script>
            <?php
        }
        else
        {
            ?>
            <script>
            alert('Connection Failed...');
            window.location.href='Contact-Us.php';
            </script>
            <?php
        }
$conn->close();
}

?>
  • This script is used for two different pages btw. i already tried if it works for just one webpage but still same result. doesnt work... – exztream02 Jan 28 '19 at 09:30
  • Possible duplicate of https://stackoverflow.com/questions/4261133/notice-undefined-variable-notice-undefined-index-and-notice-undefined – 04FS Jan 28 '19 at 09:33
  • The question is very confusing. First you say it works offline, but later you say "because my registration form works just fine online". – Barmar Jan 28 '19 at 09:34
  • 6
    _“Connection.php works fine i can connect to the database”_ - the first line of your error log screenshot indicates absolutely otherwise. – 04FS Jan 28 '19 at 09:34
  • Not the error, but you mix up `$firstname`, `$name`, and `$first_name`, and you should use prepared statements! – Ken Y-N Jan 28 '19 at 09:41
  • yeah sorry for my bad habit of writing codes.. hehe this form is for a customer to submit their forms while my "registration form" is for the admins only. the registration works fine but this code " contact Us form" doesnt work.. – exztream02 Jan 29 '19 at 00:30
  • i really need help. please someone respond to my post :( – exztream02 Feb 07 '19 at 02:55

1 Answers1

0

I finally fixed my problem after re writing my codes. turns out the problem was on my SQL Table.. the rows doesn't have collation and all rows turned into "int" didnt know what triggers it on godaddy myphpAdmin but it works fine on my wamp when using my local