1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

need a liitle help with this form and database

Discussion in 'PHP' started by dougvcd, Jun 29, 2007.

  1. #1
    ok i have a form with 7 fields and a database with 8 fields
    what i want to do is instead of peeps entering data in a 8th field on form
    i want it to be a fixed text entry eg "pic0.jpeg" and then that will go to last field in database
    hope you can understand what i am trying to do
    this is the form

    <form action="add.php" method="post">
    <div id="info" style="width:360px;">
    
        <div align="left">
          <input type="text" name="name"> 
          <strong>Name:</strong>    <br>
          <br />
          <input type="text" name="username"> 
          <strong>Username:</strong>    <br>
          <br />
          <input type="text" name="password"> 
          <strong>Password:</strong>    <br> 
          <br />
          <input type="text" name = "email"> 
          <strong>Email      </strong><br>
          <br />
          <input type="text" name="parkname"> 
          <strong>Park Name:</strong>    <br>
          <br />
          <input type="text" name="parklocation"> 
          <strong>Park Location</strong>:
        <br>
          <br />
          <input type="text" name="caravandetails"> 
          <strong>Caravan Details</strong>:
        <p><strong>
        <br/>
          <input type="submit" value="submit"/> 
        </div>
    </form>
    HTML:
    <?php 
    
    //This gets all the other information from the form 
    $name=$_POST['name'];
    $username=$_POST['username'];
    $password=$_POST['password'];
    $email=$_POST['email']; 
    $parkname=$_POST['parkname'];
    $parklocation=$_POST['parklocation'];
    $caravandetails=$_POST['caravandetails']; 
    $pname=$_POST['pname'];
    // Connects to your Database 
    mysql_connect("s", "d", "s") or die(mysql_error()); 
    mysql_select_db("u") or die(mysql_error()); 
    
    //Writes the information to the database 
    mysql_query("INSERT INTO `members` VALUES ('$name', '$username', '$password', '$email', '$parkname', '$parklocation', '$caravandetails', '$pname')"); 
     
    		
    ?> 
    PHP:
     
    dougvcd, Jun 29, 2007 IP
  2. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #2
    I think i know what you mean if i understand correctly you could simply just add a hidden input field e.g.

    <form action="add.php" method="post">
    <div id="info" style="width:360px;">
    
        <div align="left">
          <input type="hidden" name="pname" value="pic0.jpeg">
          <input type="text" name="name">
          <strong>Name:</strong>    <br>
          <br />
          <input type="text" name="username">
          <strong>Username:</strong>    <br>
          <br />
          <input type="text" name="password">
          <strong>Password:</strong>    <br>
          <br />
          <input type="text" name = "email">
          <strong>Email      </strong><br>
          <br />
          <input type="text" name="parkname">
          <strong>Park Name:</strong>    <br>
          <br />
          <input type="text" name="parklocation">
          <strong>Park Location</strong>:
        <br>
          <br />
          <input type="text" name="caravandetails">
          <strong>Caravan Details</strong>:
        <p><strong>
        <br/>
          <input type="submit" value="submit"/>
        </div>
    </form>
    Code (markup):
    That would add pic0.jpeg in the last field of the table.
     
    adamjblakey, Jun 29, 2007 IP
  3. crazyryan

    crazyryan Well-Known Member

    Messages:
    3,087
    Likes Received:
    165
    Best Answers:
    0
    Trophy Points:
    175
    #3
    You need to look into securing that as well.
     
    crazyryan, Jun 29, 2007 IP
  4. dougvcd

    dougvcd Peon

    Messages:
    267
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    a big thanks worked a treat
    when i have all running will then look at security
    cheers
    Doug
     
    dougvcd, Jun 29, 2007 IP