PHP $_POST not sending data from form -
i'm trying send data form database can't seem reason. have tried bunch of stuff, troubleshooting know, guess beyond scope of database knowledge -- month or 2 in. these 2 files trying send data between, no avail. can please explain going on?! much!
maintenancereps.php
<html> <head> <title>maintenance : reps</title> <style type="text/css"> .style1 { margin-top: 114px; } .style2 { border-width: 0px; } .style3 { color: #000080; font-size: 26pt; font-family: calibri; } .auto-style1 { text-align: right; } .auto-style2 { text-align: center; } .auto-style3 { border: 1px solid #000000; background-color: #c0c0c0; } </style> </head> <body> <center><a href="http://acadweb1.salisbury.edu/~vg7308/premiereproductshome.html"> <span class="style3"> <img alt="" src="img2.gif" width="100" height="100" style="float: left" class="style2"> </span></a><span class="style3">rep maintenance<hr></span></center></body> <table align="center" class="auto-style3"> <tr> <td class="auto-style1">rep num:</td> <td> <input type="text" maxlength="32" name="repnum" value="< =$_post['rep_num']?>"></td> </tr> <tr> <td class="auto-style1">last name:</td> <td> <input type="text" maxlength="32" name="lastname" value="<?=$_post['last_name']?>"></td> </tr> <tr> <td class="auto-style1">first name:</td> <td> <input type="text" maxlength="32" name="firstname" value="<?=$_post['first_name']?>"></td> </tr> <tr> <td class="auto-style1">street:</td> <td> <input type="text" maxlength="32" name="street" value="<?=$_post['street']?>"></td> </tr> <tr> <td class="auto-style1">city</td> <td> <input type="text" maxlength="32" name="city" value="<?=$_post['city']?>"></td> </tr> <tr> <td class="auto-style1">state:</td> <td> <input type="text" maxlength="32" name="state" value="<?=$_post['state']?>"></td> </tr> <tr> <td class="auto-style1">zip:</td> <td> <input type="text" maxlength="32" name="zip" value="<?=$_post['zip']?>"></td> </tr> <tr> <td class="auto-style1">commission:</td> <td> <input type="text" maxlength="32" name="commission" value="<?=$_post['commission']?>"></td> </tr> <tr> <td class="auto-style1">rate:</td> <td> <input type="text" maxlength="32" name="rate" value="<?=$_post['rate']?>"></td> </tr> <tr> <td class="auto-style2" colspan="2"> <?php var_dump($_post); ?> <form action="" method="post" enctype="multipart/form-data"> <input type = "submit" name ="insert" value = "insert" /> <input type = "submit" name = "search" value = "search" /> <input type = "submit" name = "modify" value = "modify" /> <input type = "submit" name = "delete" value = "delete" onclick="return confirm('are sure want delete rep?')" /> </form> </td> </tr> </table> <?php include "repsadd.php"; ?> </body> </html>
repsadd.php
<html> <head> <title>maintenance : reps</title> </head> <?php session_start(); //address error handling ini_set('display_errors',1); error_reporting(e_all & ~e_notice); //define rep number php variable name //attempt connect if($connection = @mysql_connect ('localhost', 'username','password')){ //print '<p>succesfully connected mysql.</p>'; } else{ die('<p>could not connect mysql because: <b>' .mysql_error() .'</b></p>'); } if (@mysql_select_db("giuliana_premiere",$connection)){ //print '<p>the giuliana_premiere database has been selected.</p>'; } else { die('<p>could not select giuliana_premiere database because: <b>'.mysql_error().'</b></p>'); } //output resulting query table if(isset($_post['insert'])){ if(empty($_request['repnum']) || empty($_request['lastname']) || empty($_request['firstname']) || empty($_request['street']) || empty($_request['city']) || empty($_request['state']) || empty($_request['zip']) || empty($_request['commission']) || empty($_request['rate'])){ print "there information missing form."; } else{ $repnum = $_post['repnum']; $lastname = $_post['lastname']; $firstname = $_post['firstname']; $street = $_post['street']; $city = $_post['city']; $state = $_post['state']; $zip = $_post['zip']; $commission = $_post['commission']; $rate = $_post['rate']; $query = mysql_query("insert rep values ('$repnum', '$lastname', '$firstname', '$street', '$city', '$state', '$zip', '$commission', '$rate')"); print "succesfully inserted rep"; $query2 = "select * rep rep_num = '$repnum'"; if($r = mysql_query($query2)){ while ($row = mysql_fetch_array($r)){ print "{$row['last_name']}, {$row['first_name']}<br>"; print "{$row['street']} {$row['city']}, {$row['state']} {$row['zip']}<br>"; print "<b>{$row['rep_num']}</b> | $ {$row['commission']} | {$row['rate']}<br>"; } } } } if(isset($_post['modify'])){ if(empty($_request['repnum']) || empty($_request['lastname']) || empty($_request['firstname']) || empty($_request['street']) || empty($_request['city']) || empty($_request['state']) || empty($_request['zip']) || empty($_request['commission']) || empty($_request['rate'])){ print "there information missing form."; } else{ $repnum = $_post['repnum']; $lastname = $_post['lastname']; $firstname = $_post['firstname']; $street = $_post['street']; $city = $_post['city']; $state = $_post['state']; $zip = $_post['zip']; $commission = $_post['commission']; $rate = $_post['rate']; $query = mysql_query("update rep set rep_num = '$repnum',last_name = '$lastname', first_name = '$firstname',street = '$street', city = '$city', state = '$state',zip = '$zip', commission = '$commission',rate = '$rate' rep_num = '$repnum'"); print "succesfully modified rep"; $query2 = "select * rep rep_num = '$repnum'"; if($r = mysql_query($query2)){ while ($row = mysql_fetch_array($r)){ print "{$row['last_name']}, {$row['first_name']}<br>"; print "{$row['street']} {$row['city']}, {$row['state']} {$row['zip']}<br>"; print "<b>{$row['rep_num']}</b> | $ {$row['commission']} | {$row['rate']}<br>"; } } } } if(isset($_post['delete'])){ if(empty($_request['repnum'])){ print "there information missing in form."; } else{ $repnum= $_post['repnum']; $query = mysql_query("delete rep rep_num = '$repnum'"); print"succesfully deleted rep"; } } ?> </body> </html>
all input elements should in form tag, use html
<html> <head> <title>maintenance : reps</title> <style type="text/css"> .style1 { margin-top: 114px; } .style2 { border-width: 0px; } .style3 { color: #000080; font-size: 26pt; font-family: calibri; } .auto-style1 { text-align: right; } .auto-style2 { text-align: center; } .auto-style3 { border: 1px solid #000000; background-color: #c0c0c0; } </style> </head> <body> <center> <a href="http://acadweb1.salisbury.edu/~vg7308/premiereproductshome.html"> <span class="style3"> <img alt="" src="img2.gif" width="100" height="100" style="float: left" class="style2"> </span></a><span class="style3">rep maintenance <hr> </span> </center> </body> <?php var_dump($_post); ?> <form action="" method="post" enctype="multipart/form-data"> <table align="center" class="auto-style3"> <tr> <td class="auto-style1">rep num:</td> <td><input type="text" maxlength="32" name="repnum" value="< =$_post['rep_num']?>"></td> </tr> <tr> <td class="auto-style1">last name:</td> <td><input type="text" maxlength="32" name="lastname" value="<?=$_post['last_name']?>"></td> </tr> <tr> <td class="auto-style1">first name:</td> <td><input type="text" maxlength="32" name="firstname" value="<?=$_post['first_name']?>"></td> </tr> <tr> <td class="auto-style1">street:</td> <td><input type="text" maxlength="32" name="street" value="<?=$_post['street']?>"></td> </tr> <tr> <td class="auto-style1">city</td> <td><input type="text" maxlength="32" name="city" value="<?=$_post['city']?>"></td> </tr> <tr> <td class="auto-style1">state:</td> <td><input type="text" maxlength="32" name="state" value="<?=$_post['state']?>"></td> </tr> <tr> <td class="auto-style1">zip:</td> <td><input type="text" maxlength="32" name="zip" value="<?=$_post['zip']?>"></td> </tr> <tr> <td class="auto-style1">commission:</td> <td><input type="text" maxlength="32" name="commission" value="<?=$_post['commission']?>"></td> </tr> <tr> <td class="auto-style1">rate:</td> <td><input type="text" maxlength="32" name="rate" value="<?=$_post['rate']?>"></td> </tr> <tr> <td class="auto-style2" colspan="2"><input type = "submit" name ="insert" value = "insert" /> <input type = "submit" name = "search" value = "search" /> <input type = "submit" name = "modify" value = "modify" /> <input type = "submit" name = "delete" value = "delete" onclick="return confirm('are sure want delete rep?')" /></td> </tr> </table> </form> <?php include "repsadd.php"; ?> </body> </html>
Comments
Post a Comment