Help a database newbie :)

Discussion in 'Databases' started by bon300187, Dec 10, 2007.

  1. #1
    Hey I will try to explain what i am wanting the best i can, here goes:

    I have 2 sites - A and B. Site B uses task management softare so i can organise what i need to do with ease, it has its own database where each task is put.

    I want to be able to have a form on site A so that when i put a task in site A, site B will also be updated in the backend showing that it needs doing? How would i link a form on site A with the correct parametres etc.

    Not sure if this helps but the sites are with the same host etc.

    Any help would be appreciated.

    Thanks
     
    bon300187, Dec 10, 2007 IP
  2. Irontree

    Irontree Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    in the form parameters jsut link to the update script in site B

    action="siteb.com/process.php" method="post"
     
    Irontree, Dec 10, 2007 IP
  3. bon300187

    bon300187 Peon

    Messages:
    1,475
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey, thanks for the quick reply. A few questions though (i have never done anything like this with databases).

    How would i get each box going to the relevant bit in the database - such as title, description etc. Would i add the same lable in each box in the form?

    Also should i have a file called process.php in my site B somewhere or are you just saying i need to link it to the file in site B that updates the database?
     
    bon300187, Dec 10, 2007 IP
  4. Irontree

    Irontree Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    It doesn't have to be called process. Here take a look at something like this.

       1.
          <?php //page1.php
       2.
          $link=mysql_connect($hostname, $username, $password);
       3.
          mysql_select_db($dbid) or die("unable to connect");
       4.
          $x = $_GET['name'];
       5.
          $result=mysql_query("SELECT * FROM table1 where name='$x'") or die("ERROR:".mysql_error());
       6.
          $row=mysql_fetch_array($result,MYSQL_ASSOC); //since it returns only 1 row.
       7.
          print '<form method="POST" action="page2.php">';
       8.
          print '<input type="hidden" name="oldname" value="'.$variable.'">';
       9.
          print 'Name<input type="text" maxlength="19" size="53" name="name" value="'.$row['name'].'" />';
      10.
          print '<input type="submit" name="submit" value="Update">';
      11.
          mysql_close($link);
      12.
          ?>
      13.
           
      14.
          <?php //page2.php
      15.
          $link=mysql_connect($hostname, $username, $password);
      16.
          mysql_select_db($dbid) or die("unable to connect");
      17.
          $old_name=$_POST['oldname'];
      18.
          $new_name=$_POST['name'];
      19.
          mysql_query("UPDATE table1 SET name='$new_name' where name='$old_name'") or die("ERROR:".mysql_error());
      20.
          echo "thanks";
      21.
          mysql_close($link);
      22.
          ?>
    PHP:
    It's not my code, but it should give you an idea. Basically you'll be passing the input fields as variables to your DB.
     
    Irontree, Dec 10, 2007 IP
  5. bon300187

    bon300187 Peon

    Messages:
    1,475
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Ok ill have a play around with it but im not too sure what i'm doing :D

    If anyone else has info etc to make it easier or know any tutorials that may explain the process don't hesitate to reply.
     
    bon300187, Dec 10, 2007 IP
  6. codesome

    codesome Peon

    Messages:
    98
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Irontree is right.
    I can suggest you to use iframe in your HTML code. But this will only affect site B database.
     
    codesome, Dec 10, 2007 IP
  7. bon300187

    bon300187 Peon

    Messages:
    1,475
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #7
    So that code would work? If i just add my DB details from site b?
     
    bon300187, Dec 10, 2007 IP
  8. Irontree

    Irontree Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Post whatever code it is you got right now.
     
    Irontree, Dec 10, 2007 IP
  9. bon300187

    bon300187 Peon

    Messages:
    1,475
    Likes Received:
    53
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I dont have any yet, i am using taskfreak to get the manual way of doing it and have a database set up for that.

    I want to create a form on a different website which will input the data into the correct tables etc and then show in taskfreak's backend.
     
    bon300187, Dec 10, 2007 IP
  10. Irontree

    Irontree Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Well, if I were you I'd see if taskfreak has a forum and ask there, also try phpbuilder for help. I have never used taskfreak, so I am unsure what their db schema looks like.
     
    Irontree, Dec 10, 2007 IP