*MAFIA* Forums
Miscellaneous => Spam => Topic started by: *MAFIA* Capsloc on April 08, 2009, 06:37:24 PM
-
Ok, so i'm working on this web application for my pops....
<HTML><style type="text/css">
<!--
body {
background-image: url(../background.png);
}
-->
</style>
<title>Uruapan Auto Management System</title><BODY>
<p align="center">Uruapan Auto Management System</p>
<p> </p>
<form action='add_insert.php' method='post'>
<table width="449" border="1" align="center">
<tr>
<td width="162" height="23"><div align="right">Vehicle Make:</div></td>
<td width="271"><div align="left">
<?php
*******************
all connection info here
*******************
$query = "SELECT make FROM vehicle_make ORDER BY make";
$result = mysql_query($query)
or die ("Couldn't execute query");
$options="";
while ($row=mysql_fetch_array($result)) {
$make=$row["make"];
$options.="<OPTION VALUE=\"$make\">".$make.'</option>';
} ?>
<SELECT NAME="make">
<OPTION VALUE=0>
<?php echo $options ?>
</select>
</div></td>
</tr>
<tr>
<td height="23"><div align="right">Model</div></td>
<td><label>
<input name="model" type="text" id="model" maxlength="25">
</label></td>
</tr>
<tr>
<td height="23"><div align="right">Year:</div></td>
<td><input name="auto_year" type="text" id="auto_year" maxlength="4"></td>
</tr>
<tr>
<td height="23"><div align="right">Color:</div></td>
<td><input name="color" type="text" id="color" maxlength="15"></td>
</tr>
<tr>
<td height="23"><div align="right">Miles:</div></td>
<td><input name="miles" type="text" id="miles" maxlength="6"></td>
</tr>
<tr>
<td height="23"><div align="right">Price:</div></td>
<td><input name="price" type="text" id="price" maxlength="5"></td>
</tr>
<tr>
<td height="23"><div align="right">VIN</div></td>
<td><input name="VIN" type="text" id="VIN" maxlength="17"></td>
</tr>
<tr>
<td height="23"><div align="right">Approved:</div></td>
<td>
<input type="radio" name="approved" id="radio" value="1">
Yes |
<input name="approved" type="radio" id="radio2" value="0" checked>
No </td>
</tr>
<tr>
<td height="23"> </td>
<td><label>
<input type="submit" name="Submit" id="Submit" value="Submit">
<input type="reset" name="Reset" id="reset" value="Reset">
</label></td>
</tr>
</table>
</form>
</BODY>
</HTML>
Now all that works fine when inserting through my add_insert.php page. Thing is, I need to add an upload field there, that will insert an image of the vehicle into my mysql database. I was reading up and i saw lots of tutorials with an image upload form. But nothing about imageupload along with more data than just the image.
Any ideas on how this might work? Here is the code for my add_insert.php page
<?php
***********************
connection info here
***********************
$connection = mysql_connect($host, $username, $password)
or die ("Couldn't connect to server!");
$db = mysql_select_db($database,$connection)
or die ("Couldn't connect to server!");
//Replace with your MySQL DB Name
$make=mysql_real_escape_string($_POST['make']); //This value has to be the same as in the HTML form file
$model=mysql_real_escape_string($_POST['model']);
$auto_year=mysql_real_escape_string($_POST['auto_year']);
$color=mysql_real_escape_string($_POST['color']);
$miles=mysql_real_escape_string($_POST['miles']);
$price=mysql_real_escape_string($_POST['price']);
$VIN=mysql_real_escape_string($_POST['VIN']);
$approved=mysql_real_escape_string($_POST['approved']); //This value has to be the same as in the HTML form file
// the following inserts all new data stored in the variables above, that were taken from the previous form
$sql="INSERT INTO inventory (make,model,auto_year,color,miles,price,VIN,approved) VALUES ('$make','$model','$auto_year','$color','$miles','$price','$VIN','$approved')";
if (!mysql_query($sql,$connection)) {
die('Error: ' . mysql_error());
}
echo "The form data was successfully added to your database.";
mysql_close($connection);
?>
<a href="index.php">Go Back</a>
-
double post but nvm i figured out a way around it...kinda
Once the text data is inputted, i will enter it to the database then i will take them to the image upload page and do something like
$query = "select id from inventory order by id desc limit 1"
$id = mysql_query($query)
$result = mysql_query("UPDATE inventory SET car_pic='$upload_car' WHERE id='$id'")
that will select the last row created and transfer the data stored in $upload_car which would be the binary data for the pic and i would upload filetype and filename too.
let me know wut u think about that idea.
-
My PHP isn't as nearly up to par as Boner's but the SQL looks great.
Try it out and let me know how it works.
-
i don't know shit about php!
-
i don't know shit about php!
k, sure you don't.
-
i don't know shit about php!
I knew it all along.
-
Ok, so i'm working on this web application for my pops....
<HTML><style type="text/css">
<!--
body {
background-image: url(../background.png);
}
-->
</style>
<title>Uruapan Auto Management System</title><BODY>
<p align="center">Uruapan Auto Management System</p>
<p> </p>
<form action='add_insert.php' method='post'>
<table width="449" border="1" align="center">
<tr>
<td width="162" height="23"><div align="right">Vehicle Make:</div></td>
<td width="271"><div align="left">
<?php
*******************
all connection info here
*******************
$query = "SELECT make FROM vehicle_make ORDER BY make";
$result = mysql_query($query)
or die ("Couldn't execute query");
$options="";
while ($row=mysql_fetch_array($result)) {
$make=$row["make"];
$options.="<OPTION VALUE=\"$make\">".$make.'</option>';
} ?>
<SELECT NAME="make">
<OPTION VALUE=0>
<?php echo $options ?>
</select>
</div></td>
</tr>
<tr>
<td height="23"><div align="right">Model</div></td>
<td><label>
<input name="model" type="text" id="model" maxlength="25">
</label></td>
</tr>
<tr>
<td height="23"><div align="right">Year:</div></td>
<td><input name="auto_year" type="text" id="auto_year" maxlength="4"></td>
</tr>
<tr>
<td height="23"><div align="right">Color:</div></td>
<td><input name="color" type="text" id="color" maxlength="15"></td>
</tr>
<tr>
<td height="23"><div align="right">Miles:</div></td>
<td><input name="miles" type="text" id="miles" maxlength="6"></td>
</tr>
<tr>
<td height="23"><div align="right">Price:</div></td>
<td><input name="price" type="text" id="price" maxlength="5"></td>
</tr>
<tr>
<td height="23"><div align="right">VIN</div></td>
<td><input name="VIN" type="text" id="VIN" maxlength="17"></td>
</tr>
<tr>
<td height="23"><div align="right">Approved:</div></td>
<td>
<input type="radio" name="approved" id="radio" value="1">
Yes |
<input name="approved" type="radio" id="radio2" value="0" checked>
No </td>
</tr>
<tr>
<td height="23"> </td>
<td><label>
<input type="submit" name="Submit" id="Submit" value="Submit">
<input type="reset" name="Reset" id="reset" value="Reset">
</label></td>
</tr>
</table>
</form>
</BODY>
</HTML>
Now all that works fine when inserting through my add_insert.php page. Thing is, I need to add an upload field there, that will insert an image of the vehicle into my mysql database. I was reading up and i saw lots of tutorials with an image upload form. But nothing about imageupload along with more data than just the image.
Any ideas on how this might work? Here is the code for my add_insert.php page
<?php
***********************
connection info here
***********************
$connection = mysql_connect($host, $username, $password)
or die ("Couldn't connect to server!");
$db = mysql_select_db($database,$connection)
or die ("Couldn't connect to server!");
//Replace with your MySQL DB Name
$make=mysql_real_escape_string($_POST['make']); //This value has to be the same as in the HTML form file
$model=mysql_real_escape_string($_POST['model']);
$auto_year=mysql_real_escape_string($_POST['auto_year']);
$color=mysql_real_escape_string($_POST['color']);
$miles=mysql_real_escape_string($_POST['miles']);
$price=mysql_real_escape_string($_POST['price']);
$VIN=mysql_real_escape_string($_POST['VIN']);
$approved=mysql_real_escape_string($_POST['approved']); //This value has to be the same as in the HTML form file
// the following inserts all new data stored in the variables above, that were taken from the previous form
$sql="INSERT INTO inventory (make,model,auto_year,color,miles,price,VIN,approved) VALUES ('$make','$model','$auto_year','$color','$miles','$price','$VIN','$approved')";
if (!mysql_query($sql,$connection)) {
die('Error: ' . mysql_error());
}
echo "The form data was successfully added to your database.";
mysql_close($connection);
?>
<a href="index.php">Go Back</a>
GIVE UP