troubleshooting Question

Have a MySQL Database, PHP Form isn't working, but connection is Successful

Avatar of mSprout
mSprout asked on
PHPWeb DevelopmentMySQL Server
34 Comments3 Solutions238 ViewsLast Modified:
I created a PHP form, and I would like to record the results to a database. When I test the connection file on its own it is successful. When I attempt to include the file with the connection instead, the form does not save the information? Am I missing a step here?

<body onload="myUploadFunction()">
  <!-- Primary Page Layout
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <div class="container">
    <div class="row">
      <div class="one column" style="margin-top: 2%">

         if(isset($_POST['add'])) {
         require '*********.php';
            if(! get_magic_quotes_gpc() ) {
               $PTitle = addslashes ($_POST['PTitle']);
               $PContent = addslashes ($_POST['PContent']);
            }else {
               $PTitle = $_POST['$PTitle'];
               $PContent = $_POST['PContent'];
            $PType = $_POST['PType'];
            $PDisplay = $_POST['PDisplay'];
            $POrder = $_POST['POrder'];
            $retval = mysql_query( $sql, $conn );
            if(! $retval ) {
               die('Could not enter data: ' . mysql_error());
            echo "Entered data successfully\n";
         }else {

         <form method = "post" action = "dor.php">
    <legend>Create A Page</legend>
    Title: <input type="text" name="PTitle"> Page Type: <select name="PType">
  <option value="home">Home</option>  
  <option value="event">Event</option>
  <option value="vehicle">Vehicle</option>
  <option value="testimonial">Testimonial</option>
  <option value="special">Special</option>
  <option value="about">About</option>
  <option value="quote">Quote</option>
</select> Page Order: <input type="text" name="POrder"> 
  <textarea id="PContent">Please enter text and images only. Images will automatically be formatted based on the number of images included.

    <select name="PDisplay">
  <option value="False">Hide</option>  
  <option value="True">Show</option>
</select><input type="submit" id="add" value="Save">
Upload New Image:
<input type="file" id="myFile" multiple size="50" onchange="myUploadFunction()">

<p id="demo"></p>
function myUploadFunction(){
    var x = document.getElementById("myFile");
    var txt = "";
    if ('files' in x) {
        if (x.files.length == 0) {
            txt = "Select one or more files.";
        } else {
            for (var i = 0; i < x.files.length; i++) {
                txt += "<br><strong>" + (i+1) + ". file</strong><br>";
                var file = x.files[i];
                if ('name' in file) {
                    txt += "name: " + + "<br>";
                if ('size' in file) {
                    txt += "size: " + file.size + " bytes <br>";
    else {
        if (x.value == "") {
            txt += "Select one or more files.";
        } else {
            txt += "The files property is not supported by your browser!";
            txt  += "<br>The path of the selected file: " + x.value; // If the browser does not support the files property, it will return the path of the selected file instead. 
    document.getElementById("demo").innerHTML = txt;

<p><strong>Tip:</strong> Use the Control or the Shift key to select multiple files.</p>

Set Page Image:
Image: <input type="text" name="ImageLink">


<!-- End Document
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
Join our community to see this answer!
Unlock 3 Answers and 34 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 34 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros