Originally posted by Kudose
Can you post for detailed code?
this is the complete code for the php file.
<?
//// ALL FIELDS MUST CONTAIN SOMETHING
if($username=='' OR $SenderFirstName=='' OR $SenderLastName=='' OR $SenderAddress=='' OR $RecipientFirstName=='' OR
$RecipientLastName=='' OR $RecipientAddress=='' OR $LetterContent=='')
{
echo "All fields must be completed before you can send this form.";
}
elseif (!eregi("^[A-Za-z]+$", $SenderFirstName)) {
echo "Senders first name field can only contain letters A-Z or a-z with no spaces.";
}
elseif (!eregi("^[A-Za-z]+$", $SenderLastName)) {
echo "Senders last name field can only contain letters A-Z or a-z with no spaces.";
}
elseif (!eregi("^[A-Za-z]+$", $RecipientFirstName)) {
echo "Recipients first name field can only contain letters A-Z or a-z with no spaces.";
}
elseif (!eregi("^[A-Za-z]+$", $RecipientLastName)) {
echo "Recipients last name field can only contain letters A-Z or a-z with no spaces.";
}
//// IF THE FORM FIELD LABELED BrailleType IS EQUAL TO GRADE ONE BRAILLE
//// THEN THE FORM FIELD LABELED LetterContent CAN ONLY HAVE 880 CHARACTERS MAXIMUM
elseif($BrailleType=='Grade one Braille' && strlen($LetterContent) > 880)
{
echo "One page of transcribed grade one Braille is equal to a maximum of 880 characters, including spaces.";
}
//// IF THE FORM FIELD LABELED BrailleType IS EQUAL TO GRADE TWO BRAILLE
//// THEN THE FORM FIELD LABELED LetterContent CAN ONLY HAVE 1760 CHARACTERS MAXIMUM
elseif($BrailleType=='Grade two Braille' && strlen($LetterContent) > 1760)
{
echo "One page of transcribed grade two Braille is equal to a maximum of 1760 characters, including spaces.";
}
//// IF EVERYTHING FOLLOWS THE RULES, THEN SUBMIT
//// THE PAGE FOR REVIEW BY A CERTIFIED BRAILLE
//// TRANSCRIBER
else
{
include("../config.php");
$connection = mysql_connect("$server", "paddy_transcript", "transcription");
$db = mysql_select_db("paddy_transcription", $connection);
$query = "INSERT INTO $transcribe_tbl (`username`,`SenderFirstName`,`SenderLastName`,`SenderAddress`,`RecipientFirstName`,`RecipientLastName`,`RecipientAddress`,`BrailleType`,`LetterContent`) VALUES ('$username','$SenderFirstName','$SenderLastName','$SenderAddress','$RecipientFirstName','$RecipientLastName','$RecipientAddress','$BrailleType','$LetterContent')";
$result = mysql_query($query, $connection);
///THE CODE BELOW FOR THE SUBTRACTION IS NOT WORKING
$MinusOne = "1";
$NewCredits = $CreditsLeft - $MinusOne;
$query = "UPDATE account SET CreditsLeft='$NewCredits' WHERE username='$username'";
$result = mysql_query($query, $connection);
echo "<H1>Confirmation!</H1>Hi $SenderFirstName $SenderLastName,<br><br>Thank you for giving us the opportunity to transcribe a letter for you. We will send the letter free matter for the blind to $RecipientFirstName $RecipientLastName as soon as the letter is transcribed into $BrailleType.<br><br>Cordially,<br> Braille School Transcription Service.<br><a href=\"mailto:transcription@brailleschool.com\">transcription@brailleschool.com</a><hr>";
}
?>
table structure is as follows:
CREATE TABLE account (
id int(11) NOT NULL auto_increment,
username text NOT NULL,
CreditsLeft text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM AUTO_INCREMENT=4 ;