Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts

    Join two files in One .

    Hello

    I have this File , Runs and insert Data and the other file , runs and Update data.. I need to join both codes in one file and Each Code runs when an icon clicked .. I have two icon 1-insert 2-Update..

    PHP Code:
     $query =mysql_query("UPDATE  ".$DB->prefix("page")." SET name='$name' WHERE id='$id' ")
      or die(
    "can't edit the ehdaa");

      if (!
    $query){
      echo
    "<center>error</center><META HTTP-EQUIV=\"Refresh\" Content=5;URL=\"index.php\">";
      }else{
      echo
    "<center>added</center><META HTTP-EQUIV=\"Refresh\" Content=1;URL=\"index.php\">";
        } 
    PHP Code:
      $sql "INSERT INTO ".$DB->prefix("page")." (page, url) VALUES ('$page', '$url')";
    $ret = $.DB->query($sql);

      if (!
    $sql){
      echo
    "<center>error</center><META HTTP-EQUIV=\"Refresh\" Content=5;URL=\"index.php\">";
      }else{
      echo
    "<center>done</center><META HTTP-EQUIV=\"Refresh\" Content=1;URL=\"index.php\">";
        } 

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    Will need some adjustments, it gets an Undefined index: action error, but runs OK when a link is clicked.

    index.php
    PHP Code:
    <html>
    <body>
    <a href="index.php?action=insert"><img src="images/insert.jpg">Insert</a>
    <a href="index.php?action=update"><img src="images/update.jpg">Update</a>

    <?php
    $action 
    $_GET['action'];

    if (
    $action == "update") {
    echo 
    "Update"// run update query


    if (
    $action == "insert") {
    echo 
    "Insert"// run insert query
    }
    ?>

    </body>
    </html>

    --------------
    Last edited by Len Whistler; 01-20-2010 at 01:59 AM.
    Leonard Whistler

  • Users who have thanked Len Whistler for this post:

    ajloun (01-20-2010)

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    215
    Thanks
    74
    Thanked 0 Times in 0 Posts
    Thank you , and i have Solved it , Same your Way too , little Change.

    PHP Code:
      if (HtmlSpecialchars($_GET['action']) == "update"){
     
    $id HtmlSpecialchars($_GET['id']); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •