...

View Full Version : Join two files in One .



ajloun
01-19-2010, 06:58 PM
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..


$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\">";
}


$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\">";
}

Len Whistler
01-20-2010, 12:47 AM
Will need some adjustments, it gets an Undefined index: action error, but runs OK when a link is clicked.

index.php

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


--------------

ajloun
01-20-2010, 01:54 AM
Thank you , and i have Solved it , Same your Way too , little Change.


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum