Is there any way to create a new form.php
in Joomla to make this code work?
<?php
echo "<H2>Add a Car</H2><HR>";
function handleform()
{
global $UserName, $UserCarMake, $UserCarModel, $UserCarYear, $UserCarColor, $UserCarPlate;
$dbh=mysql_connect ("localhost", "username", "password");
if (!dbh)
{
die("Failed to open the Database");
}
mysql_select_db("joomladatabase");
if(mysql_errno())
{
die("<BR>" . mysql_errno().": ".mysql_error()."<BR>");
}
$query = "INSERT INTO RegisteredUserCars (UserName, UserCarMake, UserCarModel, UserCarYear, UserCarColor, UserCarPlate)
VALUES ('$UserName', '$UserCarMake', '$UserCarModel', '$UserCarYear', '$UserCarColor', '$UserCarPlate')";
$result = mysql_query($query);
if (mysql_errno())
{
die("<BR>" . mysql_errno().": ".mysql_error()."<BR>");
}
else
{
echo "Database has been updated.";
}
}
if ($beensubmitted)
{
handleform();
}
?>
<FORM METHOD="POST" ACTION="AddRegisteredCars.php">
<P><B>Enter Your Car Make</B>
<BR><INPUT TYPE="TEXT" NAME="UserCarMake"></P>
<P><B>Enter Your Car Model</B>
<BR><INPUT TYPE="TEXT" NAME="UserCarModel"></P>
<P><B>Enter Your Car Year</B>
<BR><INPUT TYPE="TEXT" NAME="UserCarYear"></P>
<P><B>Enter Your Car Color</B>
<BR><INPUT TYPE="TEXT" NAME="UserCarColor"></P>
<P><B>Enter Your Car's License Plate Number</B>
<BR><INPUT TYPE="TEXT" NAME="UserCarPlate"></P>
<BR><INPUT TYPE="HIDDEN" NAME="beensubmitted" VALUE="TRUE">
<P><INPUT TYPE="SUBMIT" NAME="submit" VALUE="SUBMIT"></P>
</FORM>
When I click the submit button a new link pops up giving me a "404 not found" page. I don't know where to put the addregisteredcars.php
file, and it's currently inside the XAMPP (Joomla 3.0) folder. Is there a different place I should have put it?
I'm using some plugin to make PHP code inside the article.
I'm using MySQLi.
I just see this code and I think I want this as my reference but I don't know what should I put in my source code.