PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, January 20, 2022

[FIXED] PHP Inserting blank values suddenly

 January 20, 2022     forms, php, phpmyadmin, post, request     No comments   

Issue

My form connects and inserts to my database just fine--except none of the values of the form are inserted. It's all blank. Please take a look at my code and see if there is anything I'm missing. I don't remember changing anything that would make this happen. I'll only include the form area (which I think is relevant. If that looks fine, I'll include more that may be affecting it. THANKS!

(edited with PHP and Html changes as they are suggested)

PHP

<?php

     $link = mysqli_connect("localhost","eativft2_steven","sgmexican", "eativft2_artistsdb");


array_walk_recursive( $_POST, 'mysqli_real_escape_string' );

$Fname = $_POST['Fname'];

$Lname = $_POST['Lname'];

$Website = $_POST['Website'];

    $Phone = $_POST['Phone'];

$Email = $_POST['Email'];

$Interests1 = $_POST['Interests1'];

    $Interests2 = $_POST['Interests2'];

$Interests3 = $_POST['Interests3'];

$PersonalStatement = $_POST['PersonalStatement'];


if($link === false){

    die("ERROR: Could not connect. " . mysqli_connect_error());

}

$result = mysqli_query($link,"INSERT INTO User (Fname, Lname, Website, Phone, Email, Interest1, Interest2, Interest3, PersonalStatement) VALUES('$Fname', '$Lname', '$Website', '$Phone', '$Email', '$Interests1', '$Interests2', '$Interests3', '$PersonalStatement')");

if(!$result){

  echo "ERROR: Could not execute $result. " . mysqli_error($link);

} else{

            echo "<h2>We got you.</h2>";

}


mysqli_close($link);

?>

HTML

<div class="modal-box" id="modal-box">

  <div class="modal-content">
    <span class="close"> X </span>

     <h2 id="modal-title">Create a profile</h2>
<form action="/Collaborate/indexxx.php" method="post" name="User">

  <label for="Fname">FIRST NAME</label><br>
  <input type="text" name="Fname" placeholder="first name" required> <br>

  <label for="Lname">LAST NAME</label><br>
  <input type="text" name="Lname" placeholder="last name" required> <br>

  <label for="Website">WEBSITE URL</label><br>
  <input type="text" name="Website" placeholder="show your work" required> <br>

  <label for="Phone">PHONE NUMBER</label><br>
  <input type="text" name="Phone" placeholder="1234567890" required> <br>

  <label for="Email">EMAIL ADDRESS</label><br>
  <input type="text" name="Email" placeholder="you@awesome.com" required><br>

      <label for="Interests1">INTERESTS</label><br>
      <select class="Interest1" id="Interests1" name="Interests1">
    <optgroup label="Audio">
        <option>ADR</option>
        <option>Audio Post</option>
        <option>Composer</option>
        <option>Electrician</option>
   <option>Foley</option>
        <option>Mixer</option>
        <option>On-Set</option>
        <option>Sound Design</option>
        <option>Studio</option>
        <option>Learning Audio</option>
</optgroup>
    <optgroup label="Animation">
    <option>Modeling</option>
    <option>Motion</option>
    <option>Lighting</option>
    <option>Backgrounds</option>
    <option>Learning Animation</option>
</optgroup>
<optgroup label="Culinary">
    <option>Baker</option>
    <option>Catering</option>
    <option>Cuisine (specify)</option>
    <option>Management</option>
    <option>Learning Culinary</option>
</optgroup>
<optgroup label="Fashion">
    <option>Costume</option>
    <option>Design</option>
    <option>Marketing</option>
    <option>Tailor</option>
    <option>Wardrobe</option>
    <option>Learning Fashion</option>
</optgroup>
<optgroup label="Gaming">
    <option>3D Artist</option>
    <option>Animator</option>
    <option>Art Director</option>
    <option>Concept Artist</option>
    <option>Environment Artist</option>
    <option>Game Tester</option>
    <option>Modeler</option>
    <option>Motion Capture</option>
    <option>Project Manager</option>
    <option>Programmer</option>
    <option>UI Artist</option>
    <option>Learning Gaming</option>
</optgroup>
<optgroup label="Industrial Design">
    <option>Product</option>
    <option>Learning Industrial Design</option>
</optgroup>
<optgroup label="Interior Design">
    <option>Commercial</option>
    <option>Drafting</option>
    <option>Environment</option>
    <option>Hospitality</option>
    <option>Institution</option>
    <option>Residential</option>
    <option>Learning Interior Design</option>
</optgroup>
<optgroup label="Photo">
    <option>Commercial</option>
    <option>Event</option>
    <option>Fashion</option>
    <option>Narrative</option>
    <option>Nature</option>
    <option>Real Estate</option>
    <option>Sports</option>
    <option>Wedding</option>
    <option>Learning Photo</option>
</optgroup>
<optgroup label="Video">
    <option>Cinematography</option>
    <option>Director</option>
    <option>Editor</option>
    <option>Producer</option>
    <option>Production Assistant</option>
    <option>Scriptwriter</option>
    <option>Learning Video</option>
</optgroup>
<optgroup label="Web Design">
    <option>Developing</option>
    <option>Interface</option>
    <option>Typography</option>
    <option>User Experience</option>
    <option>Learning Web Design</option>
</optgroup>
      </select>
      <label for="Interests2">INTERESTS</label><br>
      <select class="Interest2" id="Interests2" name="Interests2">
    <optgroup label="Audio">
        <option>ADR</option>
        <option>Audio Post</option>
        <option>Composer</option>
        <option>Electrician</option>
   <option>Foley</option>
        <option>Mixer</option>
        <option>On-Set</option>
        <option>Sound Design</option>
        <option>Studio</option>
        <option>Learning Audio</option>
</optgroup>
    <optgroup label="Animation">
    <option>Modeling</option>
    <option>Motion</option>
    <option>Lighting</option>
    <option>Backgrounds</option>
    <option>Learning Animation</option>
</optgroup>
<optgroup label="Culinary">
    <option>Baker</option>
    <option>Catering</option>
    <option>Cuisine (specify)</option>
    <option>Management</option>
    <option>Learning Culinary</option>
</optgroup>
<optgroup label="Fashion">
    <option>Costume</option>
    <option>Design</option>
    <option>Marketing</option>
    <option>Tailor</option>
    <option>Wardrobe</option>
    <option>Learning Fashion</option>
</optgroup>
<optgroup label="Gaming">
    <option>3D Artist</option>
    <option>Animator</option>
    <option>Art Director</option>
    <option>Concept Artist</option>
    <option>Environment Artist</option>
    <option>Game Tester</option>
    <option>Modeler</option>
    <option>Motion Capture</option>
    <option>Project Manager</option>
    <option>Programmer</option>
    <option>UI Artist</option>
    <option>Learning Gaming</option>
</optgroup>
<optgroup label="Industrial Design">
    <option>Product</option>
    <option>Learning Industrial Design</option>
</optgroup>
<optgroup label="Interior Design">
    <option>Commercial</option>
    <option>Drafting</option>
    <option>Environment</option>
    <option>Hospitality</option>
    <option>Institution</option>
    <option>Residential</option>
    <option>Learning Interior Design</option>
</optgroup>
<optgroup label="Photo">
    <option>Commercial</option>
    <option>Event</option>
    <option>Fashion</option>
    <option>Narrative</option>
    <option>Nature</option>
    <option>Real Estate</option>
    <option>Sports</option>
    <option>Wedding</option>
    <option>Learning Photo</option>
</optgroup>
<optgroup label="Video">
    <option>Cinematography</option>
    <option>Director</option>
    <option>Editor</option>
    <option>Producer</option>
    <option>Production Assistant</option>
    <option>Scriptwriter</option>
    <option>Learning Video</option>
</optgroup>
<optgroup label="Web Design">
    <option>Developing</option>
    <option>Interface</option>
    <option>Typography</option>
    <option>User Experience</option>
    <option>Learning Web Design</option>
</optgroup>
      </select>
      <label for="Interests3">INTERESTS</label><br>
      <select class="Interest3" id="Interests3" name="Interests3">
    <optgroup label="Audio">
        <option>ADR</option>
        <option>Audio Post</option>
        <option>Composer</option>
        <option>Electrician</option>
   <option>Foley</option>
        <option>Mixer</option>
        <option>On-Set</option>
        <option>Sound Design</option>
        <option>Studio</option>
        <option>Learning Audio</option>
</optgroup>
    <optgroup label="Animation">
    <option>Modeling</option>
    <option>Motion</option>
    <option>Lighting</option>
    <option>Backgrounds</option>
    <option>Learning Animation</option>
</optgroup>
<optgroup label="Culinary">
    <option>Baker</option>
    <option>Catering</option>
    <option>Cuisine (specify)</option>
    <option>Management</option>
    <option>Learning Culinary</option>
</optgroup>
<optgroup label="Fashion">
    <option>Costume</option>
    <option>Design</option>
    <option>Marketing</option>
    <option>Tailor</option>
    <option>Wardrobe</option>
    <option>Learning Fashion</option>
</optgroup>
<optgroup label="Gaming">
    <option>3D Artist</option>
    <option>Animator</option>
    <option>Art Director</option>
    <option>Concept Artist</option>
    <option>Environment Artist</option>
    <option>Game Tester</option>
    <option>Modeler</option>
    <option>Motion Capture</option>
    <option>Project Manager</option>
    <option>Programmer</option>
    <option>UI Artist</option>
    <option>Learning Gaming</option>
</optgroup>
<optgroup label="Industrial Design">
    <option>Product</option>
    <option>Learning Industrial Design</option>
</optgroup>
<optgroup label="Interior Design">
    <option>Commercial</option>
    <option>Drafting</option>
    <option>Environment</option>
    <option>Hospitality</option>
    <option>Institution</option>
    <option>Residential</option>
    <option>Learning Interior Design</option>
</optgroup>
<optgroup label="Photo">
    <option>Commercial</option>
    <option>Event</option>
    <option>Fashion</option>
    <option>Narrative</option>
    <option>Nature</option>
    <option>Real Estate</option>
    <option>Sports</option>
    <option>Wedding</option>
    <option>Learning Photo</option>
</optgroup>
<optgroup label="Video">
    <option>Cinematography</option>
    <option>Director</option>
    <option>Editor</option>
    <option>Producer</option>
    <option>Production Assistant</option>
    <option>Scriptwriter</option>
    <option>Learning Video</option>
</optgroup>
<optgroup label="Web Design">
    <option>Developing</option>
    <option>Interface</option>
    <option>Typography</option>
    <option>User Experience</option>
    <option>Learning Web Design</option>
</optgroup>
      </select>
<br>
      <label for="PersonalStatement">PERSONAL STATEMENT</label><br>
      <textarea name="PersonalStatement" id="PersonalStatement" minlength="800" maxlength="1500" rows="5" cols="20" placeholder="Let us get to know you better." required></textarea><br />

      <button id="submit" name="submit"> Submit my profile </button>
    </form>
  </div>

</div>

Solution

If anyone is like me and wanting to make their URL look pretty. Make sure NOT to do it with php files. Once I edited my .htaccess to not snip the .php, everything was working again. I don't know if changing form action to [file](without .php) would work. But I am not trying!



Answered By - Steven Guerrero
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing