Welcome Guest, Not a member yet? Register   Sign In
database trying to connect
#1

[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>
&lt;form name=”web_form” id=”web_form” method=”post” action=”upload_c.php”&gt;
<p><label>Username:</label>&lt;input type=”text” name=”username” id=”username” /&gt;&lt;/p>
<p><label>Subject:</label>&lt;input type=”text” name=”subject” id=”subject” /&gt;&lt;/p>
<p><label>Comment:</label>&lt;input type="text" name="comment" id="comment" /&gt;&lt;/p>
<p><label>File:</label>&lt;input type="file" name="file" size="40" /&gt;&lt;/p>
<p><button type=”submit” value=”Submit”>Submit</button></p>
&lt;/form&gt;
upload_c.php view
Code:
&lt;?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>”;
?&gt;
home controller
Code:
&lt;?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:
&lt;?php
class Upload extends CI_Controller {
public function index()
{
  $this->load->view('pages/upload_d');
}
}

Does anyone know what i did wrong?,..




Theme © iAndrew 2016 - Forum software by © MyBB