[eluser]Captain_Fluffy_Pants[/eluser]
I'm trying to connect to a database and table and it still not working this is what i did
home.php view
Code:
<h1>home</h1>
<form name=”web_form” id=”web_form” method=”post” action=”upload_c.php”>
<p><label>Username:</label><input type=”text” name=”username” id=”username” /></p>
<p><label>Subject:</label><input type=”text” name=”subject” id=”subject” /></p>
<p><label>Comment:</label><input type="text" name="comment" id="comment" /></p>
<p><label>File:</label><input type="file" name="file" size="40" /></p>
<p><button type=”submit” value=”Submit”>Submit</button></p>
</form>
upload_c.php view
Code:
<?php
$host=”localhost”;
$user_name=”user_name”;
$password=”password″;
$database_name=”database_name”;
$db=mysql_connect($host, $user_name, $password);
if (mysql_error() > “”) print mysql_error() . “<br>”;
mysql_select_db($database_name, $db);
if (mysql_error() > “”) print mysql_error() . “<br>”;
$username = $_POST["username"];
$subject = $_POST["subject"];
$comment = $_POST["comment"];
$file = $_POST["file"];
$submitdate = date(”Ymd”);
$query = “insert into upload_data (username, subject, comment, file, submitdate) values (’” . $username . “‘, ‘” . $subject . “‘, ” . $comment . “, ‘” . $file . “‘, ‘” . $submitdate . “‘)”;
$result = mysql_query($query);
echo “<h1>Thank you for submitting your details!</h1>”;
?>
home controller
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Home extends CI_Controller {
public function index()
{
$data = array(
'title' => 'lulzlab - every lulz has a story'
);
$this->load->view('template/header', $data);
$this->load->view('pages/home');
$this->load->view('template/footer');
}
}
upload controller
Code:
<?php
class Upload extends CI_Controller {
public function index()
{
$this->load->view('pages/upload_d');
}
}
Does anyone know what i did wrong?,..