Jump to content

Recommended Posts

Hello.

 

I have ran into a problem, but I dont know where the problem is.  I have a form, and the data in the form I would like to post to my database.  After I submit the form it says my thank you message, but nothing adds to the table.  Here is my coding

 

Coding for my Form

<?    // DISPLAY RECRUITMENT STATUS INFORMATION 
    $query = "SELECT * FROM about"; 
    $result = mysql_query($query) or die(mysql_error()); 
    while ($row = mysql_fetch_array($result)) {
?>
        <form method="post" action="processapp.php"><td valign="top\" class="NewsHeader">     Recruitment Application</td>
      </tr>
      <tr>
        <td class="norm">Recruitment Status: <span class="normbold"><?php echo"". $row['recruitment'] ."" ?><?php } ?></span></td>
      </tr>
      <tr>
        <td class="norm">Thank you for showing interest in joining Next Level Gaming. Please complete the below recruitment application. Sending this application is an acknowledgement that you have read our guidelines.</td>
      </tr>
      <tr>
        <td class="norm"> </td>
  </tr>
      <tr>
        <td class="normbold">Personal Information</td>
      </tr>
      <tr>
        <td class="norm">Your Real First Name: 
          <label>
          <input name="rlname" type="text" class="datetime" id="rlname" size="15" maxlength="15" />
        </label></td>
    </tr>
      <tr>
        <td class="norm">Birthdate: 
        <input name="dob" type="text" class="datetime" id="dob" size="10" maxlength="10" /> 
        (ex. 01-01-2008)</td>
      </tr>
      <tr>
        <td class="norm">Location: 
        <input name="location" type="text" class="datetime" id="location" size="15" maxlength="50" /></td>
      </tr>
      <tr>
        <td class="norm">Connection: 
          <label>
          <select name="connection" class="datetime" id="connection">
            <option value=" "> </option>
            <option value="T1" selected="selected">T1 or Higher</option>
            <option value="Cable">Cable</option>
            <option value="DSL">DSL</option>
            <option value="Dial-Up">Dial-Up</option>
            </select>
        </label></td>
      </tr>
      <tr>
        <td class=\"norm\"> </td>
      </tr>
      <tr>
        <td class="normbold">Contact Information</td>
      </tr>
      <tr>
        <td class="norm">Email: 
        <input name="email" type="text" class="datetime" id="email" size="25" maxlength="25" /></td>
      </tr>
      <tr>
        <td class="norm">AIM: 
        <input name="aim" type="text" class="datetime" id="aim" size="25" maxlength="25" /></td>
      </tr>
      <tr>
        <td class="norm">MSN: 
        <input name="msn" type="text" class="datetime" id="msn" size="25" maxlength="25" /></td>
      </tr>
      <tr>
        <td class="norm">Yahoo: 
        <input name="yahoo" type="text" class="datetime" id="yahoo" size="25" maxlength="25" /></td>
      </tr>
      <tr>
        <td class="norm">Xfire: 
        <input name="xfire" type="text" class="datetime" id="xfire" size="25" maxlength="25" /></td>
      </tr>
      <tr>
        <td class="norm">GSC: 
        <input name="gsc" type="text" class="datetime" id="gsc" size="25" maxlength="25" /></td>
      </tr>
      <tr>
        <td class="norm">Steam: 
        <input name="steam" type="text" class="datetime" id="steam" size="25" maxlength="50" /></td>
      </tr>
      <tr>
        <td class="norm"> </td>
      </tr>
      <tr>
        <td class="normbold">Game Information</td>
      </tr>
      <tr>
        <td class="norm">In-Game Name: 
        <input name="name" type="text" class="datetime" id="name" size="25" maxlength="25" /></td>
      </tr>
      <tr>
        <td class="norm"><p>Experience: 
            <label>
            <select name="exp" class="datetime" id="exp">
              <option selected="selected"> </option>
              <option value="DoDb">Day of Defeat Beta</option>
              <option value="DoD 1.0">Day of Defeat 1.0 (Retail)</option>
              <option value="DoD 1.1">Day of Defeat 1.1 (Steam)</option>
              <option value="DoD 1.2">Day of Defeat 1.2</option>
              <option value="DoD 1.3">Day of Defeat 1.3 (Current)</option>
              </select>
            </label>
        </p>          </td>
      </tr>
      <tr>
        <td class="norm">Allied Class:        
          <select name="allies" class="datetime" id="allies">
            <option value=" " selected="selected"> </option>
            <option value="Rifleman">Rifleman</option>
            <option value="Staff Sergeant">Staff Sergeant</option>
            <option value="Sergeant">Sergeant</option>
            <option value="Master Sergeant">Master Sergeant</option>
            <option value="Sniper">Sniper</option>
            <option value="Support Infantry">Support Infantry</option>
            <option value="Machine Gunner">Machine Gunner</option>
            </select></td>
      </tr>
      <tr>
        <td class="norm">Axis Class:        
          <select name="axis" class="datetime" id="axis">
            <option value=" " selected="selected"> </option>
            <option value="Grenadier">Grenadier</option>
            <option value="Stosstrupe">Stosstrupe</option>
            <option value="Unteroffizier">Unteroffizier</option>
            <option value="Sturmtrupe">Sturmtrupe</option>
            <option value="Scharfshutze">Scharfshutze</option>
            <option value="MG-34">MG-34</option>
            <option value="MG-42">MG-42</option>
            </select></td>
      </tr>
      <tr>
        <td class="norm">Map: 
        <input name="map" type="text" class="datetime" id="map" size="25" maxlength="25" /></td>
      </tr>
      <tr>
        <td class="norm">Game Type:        
          <select name="playertype" class="datetime" id="playertype">
            <option value=" "> </option>
            <option value="Camper">Camper</option>
            <option value="Pace Controlling">Pace Controlling</option>
            <option value="All-Around">All-Around</option>
            <option value="Rusher">Rusher</option>
            </select></td>
      </tr>
      <tr>
        <td class="norm"> </td>
      </tr>
      <tr>
        <td class="normbold">League Experience</td>
      </tr>
      <tr>
        <td class="norm"><label>
          <textarea name="leagueexp" id="leagueexp" cols="45" rows="5"></textarea>
        </label></td>
      </tr>
      <tr>
        <td class="norm">Clan Experience</td>
      </tr>
      <tr>
        <td class="norm"><textarea name="clanexp" id="clanexp" cols="45" rows="5"></textarea></td>
      </tr>
      <tr>
        <td class=\"norm\"> </td>
      </tr>
      <tr>
        <td class="normbold">Account Information</td>
      </tr>
      <tr>
        <td class="norm">Perferred Password: 
        <input name="map2" type="password" class="datetime" id="map2" size="12" maxlength="12" /> 
        (Max 12)</td>
      </tr>
      <tr>
        <td class="norm"><label>
          <input name="submit" type="submit" class="datetime" id="submit" value="Submit" />
        </label></td>
      </tr>
  </form>

 

PHP Form Handler Code

<?    
// ADD SLASHES TO FORM OUTPUT SO PHP UNDERSTANDS IT 
$as_name = addslashes($_POST['name']); 
$as_allies = addslashes($_POST['allies']); 
$as_axis = addslashes($_POST['axis']); 
$as_steamid = addslashes($_POST['steamid']); 
$as_email = addslashes($_POST['email']); 
$as_dob = addslashes($_POST['dob']); 
$as_aol = addslashes($_POST['aol']); 
$as_yahoo = addslashes($_POST['yahoo']); 
$as_msn = addslashes($_POST['msn']); 
$as_xfire = addslashes($_POST['xfire']); 
$as_gsc = addslashes($_POST['gsc']); 
$as_steam = addslashes($_POST['steam']); 
$as_favmap = addslashes($_POST['favmap']); 
$as_location = addslashes($_POST['location']); 
$as_connection = addslashes($_POST['connection']); 
$as_rlname = addslashes($_POST['rlname']); 
$as_exp = addslashes($_POST['exp']); 
$as_playertype = addslashes($_POST['playertype']); 
$as_leagueexp = addslashes($_POST['leagueexp']);
$as_clanexp = addslashes($_POST['clanexp']); 
$as_pass = addslashes($_POST['pass']);

//TRIM RESULTS
$tr_name = trim('$as_name') ; 
$tr_allies = trim('$as_allies') ; 
$tr_axis = trim('$as_axis') ;
$tr_steamid = trim('$as_steamid') ; 
$tr_email = trim('$as_email') ;
$tr_dob = trim('$as_dob') ;
$tr_aol = trim('$as_aol') ; 
$tr_yahoo = trim('$as_yahoo') ;
$tr_msn = trim('$as_msn') ;
$tr_xfire = trim('$as_xfire') ; 
$tr_gsc = trim('$as_gsc') ; 
$tr_steam = trim('$as_steam') ;
$tr_favmap = trim('$as_favmap') ; 
$tr_location = trim('$as_location') ; 
$tr_connection = trim('$as_connection') ; 
$tr_rlname = trim('$as_rlname') ;
$tr_exp = trim('$as_exp') ; 
$tr_playertype = trim('$as_playertype') ; 
$tr_leagueexp = trim('$as_leagueexp') ;
$tr_clanexp = trim('$as_clanexp') ;
$tr_pass = trim('$as_pass') ;

$querey = "INSERT INTO roster (ID, name, rank, allies, axis, joindate, steamid, email, aim, yahoo, msn, steam, favmap, rlname, dob, location, connection, xfire, gsc, playertype, leagueexp, clanexp, user, pass) VALUES ('NULL', '$tr_name', 'Recruit', '$tr_allies', '$tr_aaxis', 'NULL', '$tr_steamid', '$tr_email', '$tr_aim', '$tr_yahoo', '$tr_msn', '$tr_steam', '$tr_favmap', '$tr_rlname', '$tr_dob', '$tr_location', '$tr_connection', '$tr_xfire', '$tr_gsc', '$tr_exp', '$tr_playertype', '$tr_leagueexp', '$tr_clanexp', 'NULL', '$tr_pass')";
$result = mysql_query($query);
if (mysql_affected_rows()) {
	echo "     Recruitment Application Processed"; echo "</td>";
      echo "</tr>";
      echo "<tr>";
        echo "<td class=\"norm\">Thank you, we have recieved your recruitment application and you will recieve a response within 2-3 days.  Good luck.</td></td>";
      echo "</tr>";
      echo "<tr>";
        echo "<td></td>"; } else {
	echo "     Recruitment Application Error"; echo "</td>";
      echo "</tr>";
      echo "<tr>";
        echo "<td class=\"norm\">There was a problem processing your application.  Please go back and send another one, or email lev@nlgaming.net with your inquiry to join Next Level Gaming.  We have been notified of this error. Error:"; ?> <?php mysql_error(); ?> <?php echo "</td></td>";
      echo "</tr>";
      echo "<tr>";
        echo "<td></td>"; }?>

 

If you need to see this page live, it is at http://www.nlgaming.net/nlgb1/recruitment.php

Link to comment
https://forums.phpfreaks.com/topic/92161-addint-data-to-mysql-from-form/
Share on other sites

Don't rely on this:

 

if (mysql_affected_rows())

 

It will return -1 if it's an error, which means your IF is true.

 

Get rid of the ID and NULL for the VALUE of the ID, you don't need it since it's set to auto_increment.

 

Echo your query to see what is actually being done.

 

Use mysql_error() after your query to see where it's failing.

If you can test your sql directly on the database, from either the command line or phpMyAdmin, it may give you a clue as to why it's not working. If you can't do this, isolate your insert query and check it that way (with mysql_error())

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.