raggy99 Posted January 8, 2016 Share Posted January 8, 2016 Hi All, I'm going stir crazy trying to find the error. I'm getting my "data inserted message". however it is not showing in phpmyadmin. P.S. I'm doing this project from scratch, with no real experience. I dabbled in php years ago. I think i stopped because i got frustrated that i could not get it to work. . Form Code <html> <head> <meta charset="utf-8"> <title>Create a Stocktakes</title> </head> <form action="processstocktake.php" name="createpi"> <table width="600" border="1"> <tbody> <tr> <td align="center" colspan="2">Create a Stocktake</td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td>Stocktake Name</td> <td><input name="stocktakename" type="text" required="required" id="stocktakename" size="50"></td> </tr> <tr> <td>Date (Month-Year)</td> <td><input name="monthyear" type="text" required="required" id="monthyear"></td> </tr> <tr> <td>Stocktake Status</td> <td><input name="active" type="text" id="active" value="Active"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><input type="reset"></td> <td align="right"><input type="submit"></td> </tr> </tbody> </table> </form> <body> </body> </html> Database connection file, when i open this file it shows a blank screen, so password it is connecting <?php $connect=mysql_connect('localhost','Username@localhost','password','Username_DBbase'); if(mysqli_connect_error($connect)) { echo 'Failed to connect, check your username and/or password'; } ?> Post script <?php include ('db.php'); $stocktakename=$_POST['StocktakeName']; $monthyear=$_POST['MonthYear']; $active=$_POST['Active']; ("INSERT INTO Stocktakes(StocktakeName,MonthYear,Active) VALUES('$stocktakename','$monthyear','$active')") or die(mysql_error()); Echo"data inserted"; mysql_close(); ?> Most of the code above i got from tutorials and customised it for my needs. I hope you can assist. be gentle i'm new. Quote Link to comment Share on other sites More sharing options...
Barand Posted January 8, 2016 Share Posted January 8, 2016 You have $stocktakename=$_POST['StocktakeName];but that does not match the name in your form <input name="stocktakename" type="text" required="required" id="stocktakename" size="50"> Quote Link to comment Share on other sites More sharing options...
raggy99 Posted January 9, 2016 Author Share Posted January 9, 2016 Hello, Thanks for the quick reply. I made the change but it didn't seam to work. so i went hunting for a new tutorial and found what looks like a cleaner code.. I am now able to increase my autoid in the db, however now the other data does not post. form data <html> <head> <meta charset="utf-8"> <title>Create a Stocktakes</title> </head> <form action="processstocktake.php" name="createpi"> <table width="600" border="1"> <tbody> <tr> <td align="center" colspan="2">Create a Stocktake</td> </tr> <tr> <td width="200"> </td> <td> </td> </tr> <tr> <td>Stocktake Name</td> <td><input name="stocktakename" type="text" required="required" size="50"></td> </tr> <tr> <td>Date (Month-Year)</td> <td><input name="monthyear" type="text" required="required"></td> </tr> <tr> <td>Stocktake Status</td> <td><input name="status" type="text" value="Open"></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><input type="reset"></td> <td align="right"><input type="submit"></td> </tr> </tbody> </table> </form> <body> </body> </html> <?php include 'db.php'; $stocktakename=$_POST['stocktakename']; $monthyear=$_POST['monthyear']; $active=$_POST['status']; mysql_query ("INSERT INTO Stocktakes(StocktakeID, StocktakeName, MonthYear, Active) VALUES (NULL, '$stocktakename', '$monthyear', '$active')") or die(mysql_error()); Echo"data inserted"; mysql_close(); ?> I think i'm missing something between the form and process script, however i even copied the name from the form to the processstocktake.php file. this is making me go insane. Quote Link to comment Share on other sites More sharing options...
benanamen Posted January 9, 2016 Share Posted January 9, 2016 (edited) You are missing the post method from your form tag. method="post" Edited January 9, 2016 by benanamen Quote Link to comment Share on other sites More sharing options...
raggy99 Posted January 9, 2016 Author Share Posted January 9, 2016 Thank you. it works. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.