*MAFIA* Forums

*MAFIA* Forums

  • May 06, 2024, 07:53:55 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome back the Arcade! Play over 100+ games to get the high score and compete against other forum members.

http://www.mafiaowns.com/index.php?action=arcade;sa=list;sortby=a2z;

Author Topic: @bunhead or balth  (Read 2442 times)

*MAFIA* Capsloc

  • *MAFIA* Member
  • Forum Member
  • Reputation: 1212
  • Offline Offline
  • Posts: 1,525
    • View Profile
    • Elusive Gamers
@bunhead or balth
« on: April 08, 2009, 06:37:24 PM »

Ok,  so i'm working on this web application for my pops....

Code: [Select]
<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>&nbsp;</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">&nbsp;</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
Code: [Select]
<?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>
Logged

*MAFIA* Capsloc

  • *MAFIA* Member
  • Forum Member
  • Reputation: 1212
  • Offline Offline
  • Posts: 1,525
    • View Profile
    • Elusive Gamers
Re: @bunhead or balth
« Reply #1 on: April 08, 2009, 07:07:06 PM »

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
Code: [Select]
$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.
Logged

*MAFIA* Balthazar

  • *MAFIA* Head
  • Forum Member
  • Reputation: 2654
  • Offline Offline
  • Posts: 2,412
    • View Profile
Re: @bunhead or balth
« Reply #2 on: April 09, 2009, 10:44:59 PM »

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.
Logged

*MAFIA* Bonehead

  • *MAFIA* Founder
  • Forum Member
  • Reputation: 2584
  • Offline Offline
  • Posts: 8,007
    • View Profile
    • *MAFIA*
Re: @bunhead or balth
« Reply #3 on: April 10, 2009, 10:43:18 PM »

i don't know shit about php!
Logged

*MAFIA* Balthazar

  • *MAFIA* Head
  • Forum Member
  • Reputation: 2654
  • Offline Offline
  • Posts: 2,412
    • View Profile
Re: @bunhead or balth
« Reply #4 on: April 11, 2009, 04:47:38 AM »

i don't know shit about php!

k, sure you don't.
Logged

*MAFIA* Capsloc

  • *MAFIA* Member
  • Forum Member
  • Reputation: 1212
  • Offline Offline
  • Posts: 1,525
    • View Profile
    • Elusive Gamers
Re: @bunhead or balth
« Reply #5 on: April 12, 2009, 03:22:22 PM »

i don't know shit about php!

I knew it all along.
Logged

*MAFIA* MAGGOT

  • *MAFIA* Admin
  • Forum Member
  • Reputation: 1389
  • Offline Offline
  • Posts: 3,144
  • OFWGKTADGAFLLBBLSBFBN
    • View Profile
Re: @bunhead or balth
« Reply #6 on: April 30, 2009, 01:23:57 PM »

Ok,  so i'm working on this web application for my pops....

Code: [Select]
<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>&nbsp;</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">&nbsp;</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
Code: [Select]
<?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
Logged


"At some point in their lives, 1 in 6 children will be abducted by the dutch." ~The fact core, Portal 2.
 

Page created in 0.036 seconds with 30 queries.