Form to submit data as uppercase to mysql

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
weblearner
Forum Newbie
Posts: 20
Joined: Wed Dec 29, 2010 9:01 am

Form to submit data as uppercase to mysql

Post by weblearner »

Hi all

How do i ensure that whatever case user enter into my form are submitted to mysql as uppercase.
Would appreciate if anyone could give some pointers. Many thanks.

This is the code:

Code: Select all

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO parts (MPN, MFR, DATECODE, `DESCRIPTION`, TOTAL) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['MPN'], "text"),
                       GetSQLValueString($_POST['MFR'], "text"),
                       GetSQLValueString($_POST['DATECODE'], "text"),
                       GetSQLValueString($_POST['DESCRIPTION'], "text"),
                       GetSQLValueString($_POST['TOTAL'], "text"));

  mysql_select_db($database_quiksol, $quiksol);
  $Result1 = mysql_query($insertSQL, $quiksol) or die(mysql_error());

  $insertGoTo = "masterdetails.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
This is my form code:

<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Part No:</td>
<td><input type="text" name="MPN" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Manufacturer:</td>
<td><input type="text" name="MFR" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Date Code:</td>
<td><input type="text" name="DATECODE" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Description:</td>
<td><input type="text" name="DESCRIPTION" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Quantity:</td>
<td><input type="text" name="TOTAL" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">&nbsp;</td>
<td><input type="submit" value="Add Part" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form></td>
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Form to submit data as uppercase to mysql

Post by josh »

strtoupper() is a PHP function that does just that.
weblearner
Forum Newbie
Posts: 20
Joined: Wed Dec 29, 2010 9:01 am

Re: Form to submit data as uppercase to mysql

Post by weblearner »

hey josh

thanks for helping...it works :)
Post Reply