如何上传图像并将同一图像回显到另一页......?

时间:2013-09-27 07:58:02

标签: php mysql

我正在学习php和phpmyadmin我想将图像上传到数据库然后将相同的图像回显到另一个页面任何人帮助我

的index.html

<html>
<body>
    <form name="form" method="post" action="insert_ac.php">
      <h1>Insert Data Into mySQL Database</h1>

            name......    <input name="name" type="text" id="name"> <br><br>
            username....  <input name="username" type="text" id="username"> <br><br>
            password..    <input name="password" type="text" id="lastname"><br><br>
            Email.....    <input name="email" type="text" id="email"><br><br>
            Upload Image....... :<input type="file" name="image" id="uploadimg"><br>
      <input type="submit" name="Submit" value="Submit">
    </form>
</body>
</html>

insert_ac.php

<?php

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="loginfour"; // Database name
$tbl_name="test_four"; // Table name

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");

// Get values from form
$username=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];
$name=$_POST['name'];

// Insert data into mysql
$sql="INSERT INTO $tbl_name(username, password, email, name)VALUES('$username', '$password', '$email', '$name')";
$result=mysql_query($sql);

// if successfully insert data into database, displays message "Successful".
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='insert.php'>Back to main page</a>";
}

else {
echo "ERROR";
}
?>

<?php
// close connection
mysql_close();
?>

我想上传图片并将其显示给insert_ac.php任何一个人协助我..........................

1 个答案:

答案 0 :(得分:0)

php页面很简单

echo($_FILES["image"]["name"]);

reference