bumba000 Posted September 4, 2008 Share Posted September 4, 2008 Hi All, I have built a form that shows up in my site until I add the php code below to inject it into my DB. As soon as I add the php for the injection I get a blank page. First of all please tell my why this is happening. Secondly please tell me if the way I am trying to write to my DB will work or not. This is loading in a page that already has a DB connection. If my injector is broken please tell me why. Okay to start with here is my table structure. websites: website_id is Primary customers_id is Index url description keywords <form method="POST"> <br><br>Your Website URL <br><br><input name="websiteUrl" type="text" size="40" maxlength="200"> <br><br>Keywords you would like help ranking for: <br><br><input name="keywords" type="text" value="Keyword, Keyword" size="40" maxlength="200"> <br><br>Enter a description of your website: <textarea name="description" cols="60" rows="4">Description of your website here. . .</textarea> <br><br> <input type="submit" name="send" value="Submit"/> </form> <?php $clientCustomersID = $_SESSION['customer_id']); $websiteURL = serialize($_POST['websiteUrl']); $keywords = serialize($_POST['keywords']); $description = serialize($_POST['description']); //Inject Customers website into client side DB if($_SERVER['REQUEST_METHOD']=='POST') { $qur="INSERT INTO websites (`customers_id`,`url`,`keywords`,`description`)values ('$clientCustomersID,$websiteURL,$keywords,$description')"; } ?> Thanks in advance, John <--- Super Newb! Link to comment https://forums.phpfreaks.com/topic/122656-my-form-is-broken-please-help/ Share on other sites More sharing options...
genericnumber1 Posted September 4, 2008 Share Posted September 4, 2008 You have some errors, such as an extra ) on line 25. add error_reporting(E_ALL); to the top of your script to catch your errors and fix them. Post here if the script still does not work I didn't look at the code itself, just for errors. Link to comment https://forums.phpfreaks.com/topic/122656-my-form-is-broken-please-help/#findComment-633358 Share on other sites More sharing options...
Ken2k7 Posted September 4, 2008 Share Posted September 4, 2008 First, put session_start() at the top of your PHP script and also, does $_SESSION['customer_id'] exists? Few more things: 1. SQL VALUES part of the line will be a syntax error. You should wrap each variable with a single quote. Not just one at the front and one at the very end. 2. You're most likely not connected to the database since I see no code for that and you didn't execute that query so obviously it won't insert anything. Link to comment https://forums.phpfreaks.com/topic/122656-my-form-is-broken-please-help/#findComment-633360 Share on other sites More sharing options...
bumba000 Posted September 4, 2008 Author Share Posted September 4, 2008 genericnumber1 my line 25 is $clientCustomersID = $_SESSION['customer_id']); EDIT: Genericnumber1 Ohhhh. I see it. That is the right line. Thanks for that! Ken2k7 there is already a session started this is in a functional cart. $_SESSION['customer_id'] exists I can echo $_SESSION['customer_id'] . $_SESSION['customer_firstname']; and come up with the correct info. Will wrapping each variable in it's own single quotes fix where you are saying " SQL VALUES part of the line will be a syntax error"? Thank you for helping, John Link to comment https://forums.phpfreaks.com/topic/122656-my-form-is-broken-please-help/#findComment-633374 Share on other sites More sharing options...
Ken2k7 Posted September 4, 2008 Share Posted September 4, 2008 <form method="POST"> <br><br>Your Website URL <br><br><input name="websiteUrl" type="text" size="40" maxlength="200"> <br><br>Keywords you would like help ranking for: <br><br><input name="keywords" type="text" value="Keyword, Keyword" size="40" maxlength="200"> <br><br>Enter a description of your website: <textarea name="description" cols="60" rows="4">Description of your website here. . .</textarea> <br><br> <input type="submit" name="send" value="Submit"/> </form> <?php session_start(); $clientCustomersID = $_SESSION['customer_id']); $websiteURL = serialize($_POST['websiteUrl']); $keywords = serialize($_POST['keywords']); $description = serialize($_POST['description']); //Inject Customers website into client side DB // Ken2k7: connect to your database here! if($_SERVER['REQUEST_METHOD']=='POST') { $qur="INSERT INTO websites (`customers_id`,`url`,`keywords`,`description`)values ('$clientCustomersID','$websiteURL','$keywords','$description')"; mysql_query($qur) or die(mysql_error()); } ?> I doubt it. You still need to connect to your database. Read my comment in the code. Link to comment https://forums.phpfreaks.com/topic/122656-my-form-is-broken-please-help/#findComment-633381 Share on other sites More sharing options...
vicodin Posted September 4, 2008 Share Posted September 4, 2008 check your HTML if you put the </form> in the wrong spot it can screw it up visually and where you have: $clientCustomersID = $_SESSION['customer_id']); it has a ) in it with no starting bracket and i dont think it is saposed to be there so make it: $clientCustomersID = $_SESSION['customer_id']; Link to comment https://forums.phpfreaks.com/topic/122656-my-form-is-broken-please-help/#findComment-633382 Share on other sites More sharing options...
Ken2k7 Posted September 4, 2008 Share Posted September 4, 2008 I forgot to do this, but you should check to see if the form is submitted before executing that PHP code. As it stands, it executes whether or not the form is submitted. Link to comment https://forums.phpfreaks.com/topic/122656-my-form-is-broken-please-help/#findComment-633390 Share on other sites More sharing options...
vicodin Posted September 4, 2008 Share Posted September 4, 2008 ya you gotta give it some kind of action. Link to comment https://forums.phpfreaks.com/topic/122656-my-form-is-broken-please-help/#findComment-633392 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.