1

hey guys i want to creat my own form in joomla and use the post method . so i download extension to make my own code in articles in joomla like this

<form action="http://localhost/ocr/includes/Create_Subject.php" method="post">

username <input type="text" name="menu_name" value=""/><br/>

password <input type="text" name="id" value=""/><br/>

<input type="submit" name="save" value="Submit" />
</form>

and then i go to my website data base and create a table called show to add into it my values which i get it from my form and also make a php file called (Create_Subject.php) and i put it in includes file in my website and called it by action like u see in my code in my html and the code of that php here

<?php 
 $coonect=mysql_connect("localhost","root","");
     if(!$coonect){
  echo "Data_base error";
    die(mysql_error());
    }
     ?>
   <?php
       $username=$_POST['menu_name'];
       $id=$_POST['id'];

       $db_select=mysql_select_db("ocr");
       if(!$db_select){
    die(mysql_error());
     echo" error";

         }
             $query= "INSERT INTO show (
            name , id ) 
            VALUES( '{$username}' ,{$id} ) " ;

                 if(mysql_query($query)){
         header("www.google.com");
           exit;
          }else{
       echo"<p> error </p>";
      }

           ?>

`

and when iam run the site show to my an error what am doing wrong any heleeeep plez ....:))

4
  • i dont know he show me an erro massage in new tab :S
    – RoMedo
    May 5, 2012 at 17:53
  • and when i put in the browser the url localhost/ocr/includes/Create_Subject.php told me that there's an error in this two lines $username=$_POST['menu_name']; $id=$_POST['id'];
    – RoMedo
    May 5, 2012 at 17:56
  • thanks @jprofitt the error was in my sql query and it's work now :) thanks for cearing
    – RoMedo
    May 5, 2012 at 18:59
  • you know you dont have to use mysql_connect("localhost","root",""); for Joomla extensions. simply use $db =& JFactory::getDBO();
    – Lodder
    May 7, 2012 at 0:58

1 Answer 1

1

Here you can find plenty of information about SQLQuering with Joomla!

http://docs.joomla.org/Accessing_the_database_using_JDatabase

You can ask anything you want if you have any trouble...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.