Jump to content

Recommended Posts

[the database connection file db.php]

 

<?php

session_start();
//connect.php

DEFINE ('DB_HOST','217.174.253.159');
DEFINE ('DB_USER','xymalfco3');
DEFINE ('DB_PASSWORD','tArq*****');
DEFINE('DB_NAME','xymalfco3');

$dbc =@mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die('Could not connect to MySql:'. mysqli_connect_error() );


?>

[/db]
==============================================================================

[the index file]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Books</title>
</head>

<body>
<form method="post">
<table>

   <tr>
       <td>WebsiteTitle:</td>
       <td><input type="text" name="websitetitle" /></td>
   </tr>
   <tr>
       <td>Link</td>
       <td><input type="text" name="link" /></td>
   </tr>
   <tr>
       <td>WebMaster</td>
       <td><input type="text" name="webmaster" /></td>
   </tr>
   <tr>
       <td>Description</td>
       <td><input type="text" name="description" /></td>
   </tr>
   <tr>
       <td> </td>
       <td><input type="submit" name="submit" value="add" /></td>
   </tr>
</table>
<?php
if (isset($_POST['submit']))
   {      
   include 'db.php';

                    $websitetitle=$_POST['websitetitle'] ;
                   $link= $_POST['link'] ;                   
                   $webmaster=$_POST['webmaster'] ;
                   $description=$_POST['description'] ;

        mysql_query("INSERT INTO `links`(WebsiteTitle,Link,WebMaster,Description)
        VALUES ('$websitetitle','$link','$webmaster','$description')");


           }
?>
</form>
<table border="1">

           <?php
           include("db.php");


           $result=mysql_query("SELECT * FROM links");

           while($test = mysql_fetch_array($result))
           {
               $id = $test['LinkID'];   
               echo "<tr align='center'>";   
               echo"<td><font color='black'>" .$test['LinkID']."</font></td>";
               echo"<td><font color='black'>" .$test['WebsiteTitle']."</font></td>";
               echo"<td><font color='black'>". $test['Link']. "</font></td>";
               echo"<td><font color='black'>". $test['WebMaster']. "</font></td>";
               echo"<td><font color='black'>". $test['Description']. "</font></td>";   
               echo"<td> <a href ='view.php?LinkID=$id'>Edit</a>";
               echo"<td> <a href ='del.php?LinkID=$id'><center>Delete</center></a>";

               echo "</tr>";
           }
           mysql_close($dbc);
           ?>
</table>

</body>
</html>

 

[nb view and edit php are not showing don't know why is this a tree directory issue? ]

 

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

 

[view.php]

 

<?php
require("db.php");
$id =$_REQUEST['LinkID'];

$result = mysql_query("SELECT * FROM links WHERE LinkID  = '$id'");
$test = mysql_fetch_array($result);
if (!$result)
       {
       die("Error: Data not found..");
       }
               $WebsiteTitle=$test['WebsiteTitle'] ;
               $Link= $test['Link'] ;                   
               $WebMaster=$test['WebMaster'] ;
               $Description=$test['Description'] ;

if(isset($_POST['save']))
{   
   $websitetitle_save = $_POST['websitetitle'];
   $link_save = $_POST['link'];
   $webmaster_save = $_POST['webmaster'];
   $description_save = $_POST['description'];

   mysql_query("UPDATE links SET WebsiteTitle ='$websitetitle_save', Link ='$link_save',
        WebMaster ='$webmaster_save',Description ='$description_save' WHERE LinkID = '$id'")
               or die(mysql_error());
   echo "Saved!";

   header("Location: index.php");           
}
mysql_close($conn);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form method="post">
<table>
   <tr>
       <td>WebsiteTitle:</td>
       <td><input type="text" name="websitetitle" value="<?php echo $WebsiteTitle ?>"/></td>
   </tr>
   <tr>
       <td>Link</td>
       <td><input type="text" name="link" value="<?php echo $Link ?>"/></td>
   </tr>
   <tr>
       <td>WebMaster</td>
       <td><input type="text" name="webmaster" value="<?php echo $WebMaster ?>"/></td>
   </tr>
   <tr>
       <td>DESCRIPTION</td>
       <td><input type="text" name="description" value="<?php echo $Description ?>"/></td>
   </tr>
   <tr>
       <td> </td>
       <td><input type="submit" name="save" value="save" /></td>
   </tr>
</table>

</body>
</html>

 

[/view]

 

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

Edited by Philip

1. Use code tags.

2. Go change your username and password. It doesn't matter that you hid some of the characters. Go do it now.

3. Post the RELEVANT sections and explain your problem. In more than one vague sentence.

Edited by Jessica

something that is extremely obvious in your code... in your db.php file you are using the msqli (with an i) API and in the others you are using the mysql (without i) API... you can't mix them in that way.

 

actually the mysql API is not maintained anymore, and it usage discouraged; In replacement you should be using the mysqli or PDO extensions

Edited by mikosiko
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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