Jump to content

My form is broken. Please help


bumba000

Recommended Posts

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

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.

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

<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.

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'];

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.