script 2 not running

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
kandarpmistry
Forum Newbie
Posts: 8
Joined: Sat Feb 13, 2010 11:28 pm

script 2 not running

Post by kandarpmistry »

script 1:

<?php
require 'formhelpers.php';
if ($_POST['_submit_check']==1) {
if ($form_errors = validate_form( )) {
show_form($form_errors, $selected);
} else {
process_form( );
}
} else {
show_form( );
}
function show_form($errors = '', $selected='') {
echo '<!doctype html public "-//w3c//dtd html 3.2//en">';
echo '<html>';
echo '<body background="querybackground.jpg">';
if ($errors) {
echo '<p style= text-align:"center"><table border="2"><tr><td><p style="text-align:center">You need to correct the following errors: </p></td></tr><tr><td><ul><li>';
echo implode('</li><li><p style=text-align:"center">',$errors);
echo '</p></li></ul></td></tr></table></p>';
}
$ENG_STATUS='unchecked';
$GUJ_STATUS='unchecked';
$HIN_STATUS='unchecked';
$MAR_STATUS='unchecked';
$selected=$_POST['srclg'];
if ($selected=='ENG')
{
$ENG_STATUS='checked';
}
else if ($selected=='GUJ')
{
$GUJ_STATUS='checked';
}
else if ($selected=='HIN')
{
$HIN_STATUS='checked';
}
else if ($selected=='MAR')
{
$MAR_STATUS='checked';
}
echo '<p>&nbsp;</p>';
echo '<p>&nbsp;</p>';
echo '<p>&nbsp;</p>';
echo '<p style= text-align:"center">';
echo '<form name="translation_input" method="POST" action="'.$_SERVER['PHP_SELF'].'">';
echo '<p style="font-family:times; color:black; font-size:30px; text-align:center">CUSTOMER TRANSLATION REQUEST FORM</p>';
echo '<p style="font-family:times; color:black; font-size:30px; text-align:center">PART I</p>';
echo '<p style="font-family:times; color:black; font-size:20px; text-align:center">If you want to avail the services of translation, please select source language:';
echo '<table>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:25px; text-align:center">SOURCE LANGUAGE</p></td>';
echo '</tr>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">ENGLISH</p></td>';
echo '<td>';
echo '<input type="radio" name="srclg" value="ENG"'.$ENG_STATUS.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">GUJARATI</p></td>';
echo '<td>';
echo '<input type="radio" name="srclg" value="GUJ"'.$GUJ_STATUS.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">HINDI</p></td>';
echo '<td>';
echo '<input type="radio" name="srclg" value="HIN"'.$HIN_STATUS.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">MARATHI</p></td>';
echo '<td>';
echo '<input type="radio" name="srclg" value="MAR"'.$MAR_STATUS.'>';
echo '</td>';
echo '</tr>';
echo '</table>';
echo '<p style="font-family:times; color:black; font-size:20px; text-align:center">';
input_submit('submit','Submit');
input_reset('reset','Reset');
echo '</p>';
echo '<input type="hidden" name="_submit_check" value="1"/>';
echo '</form>';
echo '</p>';
echo '</body>';
echo '</html>';
}
function validate_form( ) {
$errors = array( );
if ( ($_POST['srclg'] != 'ENG') && ($_POST['srclg'] != 'GUJ') && ($_POST['srclg'] != 'HIN') && ($_POST['srclg'] != 'MAR'))
{
$errors[ ] = 'Please check a category before submitting';
$selected='';
}
return $errors;
return $selected;
}
function process_form( ) {
echo '<p style="font-family:times; color:black; font-size:20px; text-align:center">Thank you for completing part I of the form, now please proceed to <a href="translationorder2.php">Part II</a>.</p>';
}
?>


script 2:

<?php
require 'formhelpers.php';
$srclg=$_POST['srclg'];
if ($_POST['_submit_check']==1) {
if ($form_errors = validate_form( )) {
show_form($form_errors, $ENG, $GUJ, $HIN, $MAR, $srclg);
} else {
process_form( );
}
} else {
show_form($srclg);
}
function show_form($errors = '', $ENG='', $GUJ='', $HIN='', $MAR='', $srclg) {
echo '<!doctype html public "-//w3c//dtd html 3.2//en">';
echo '<html>';
echo '<head>';
$ENG='unchecked';
$GUJ='unchecked';
$HIN='unchecked';
$MAR='unchecked';
if (isset($_POST['ENG'])) {
$ENG = $_POST['ENG'];

if ($ENG == 'ENG') {
$ENG = 'checked';
}
}
if (isset($_POST['GUJ'])) {
$GUJ = $_POST['GUJ'];

if ($GUJ == 'GUJ') {
$GUJ = 'checked';
}
}
if (isset($_POST['HIN'])) {
$HIN = $_POST['HIN'];

if ($HIN == 'HIN') {
$HIN = 'checked';
}
}
if (isset($_POST['MAR'])) {
$MAR = $_POST['MAR'];

if ($MAR == 'MAR') {
$MAR = 'checked';
}
}
echo '</head>';
echo '<body background="querybackground.jpg">';
if ($errors) {
echo '<p style= text-align:"center"><table border="2"><tr><td><p style="text-align:center">You need to correct the following errors: </p></td></tr><tr><td><ul><li>';
echo implode('</li><li><p style=text-align:"center">',$errors);
echo '</p></li></ul></td></tr></table></p>';
}
echo '<p>&nbsp;</p>';
echo '<p>&nbsp;</p>';
echo '<p>&nbsp;</p>';
echo '<p style= text-align:"center">';
echo '<form name="translation_input" method="POST" action="'.$_SERVER['PHP_SELF'].'">';
echo '<p style="font-family:times; color:black; font-size:30px; text-align:center">CUSTOMER TRANSLATION REQUEST INFORMATION</p>';
echo '<p style="font-family:times; color:black; font-size:30px; text-align:center">PART II</p>';
echo '<p style="font-family:times; color:black; font-size:20px; text-align:center">You have selected source language: "'.$srclg.'".</p>';
echo '<p style="font-family:times; color:black; font-size:20px; text-align:center">Now, please select target language.</p>';
echo '<table>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:25px; text-align:center">TARGET LANGUAGE</p></td>';
echo '</tr>';
if ($srclg=='ENG')
{
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">GUJARATI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="GUJ" value="GUJ"'.$GUJ.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">HINDI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="HIN" value="HIN"'.$HIN.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">MARATHI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="MAR" value="MAR"'.$MAR.'>';
echo '</td>';
echo '</tr>';
}
else if ($srclg=='GUJ')
{
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">ENGLISH</p></td>';
echo '<td>';
echo '<input type="checkbox" name="ENG" value="ENG"'.$ENG.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">HINDI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="HIN" value="HIN"'.$HIN.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">MARATHI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="MAR" value="MAR"'.$MAR.'>';
echo '</td>';
echo '</tr>';
}
else if ($srclg=='HIN')
{
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">ENGLISH</p></td>';
echo '<td>';
echo '<input type="checkbox" name="ENG" value="ENG"'.$ENG.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">GUJARATI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="GUJ" value="GUJ"'.$GUJ.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">MARATHI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="MAR" value="MAR"'.$MAR.'>';
echo '</td>';
echo '</tr>';
}
else if ($srclg=='MAR')
{
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">ENGLISH</p></td>';
echo '<td>';
echo '<input type="checkbox" name="ENG" value="ENG"'.$ENG.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">GUJARATI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="GUJ" value="GUJ"'.$GUJ.'>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td><p style="font-family:times; color:black; font-size:20px; text-align:center">HINDI</p></td>';
echo '<td>';
echo '<input type="checkbox" name="HIN" value="HIN"'.$HIN.'>';
echo '</td>';
echo '</tr>';
}
echo '</table>';
echo '<p style="font-family:times; color:black; font-size:20px; text-align:center">';
input_submit('submit','Submit');
input_reset('reset','Reset');
echo '</p>';
echo '<input type="hidden" name="_submit_check" value="1"/>';
echo '<input type="hidden" name="srclg" value="'.$srclg.'"/>'
echo '</form>';
echo '</p>';
echo '</body>';
echo '</html>';
}
function validate_form( ) {
$errors = array( );
if ($srclg=='ENG')
{
if (($_POST['GUJ'] != 'GUJ') && ($_POST['HIN'] != 'HIN') && ($_POST['MAR'] != 'MAR'))
{
$errors[ ] = 'Please check a category before submitting';
$GUJ='';
$HIN='';
$MAR='';
}
}
if ($srclg=='GUJ')
{
if (($_POST['ENG'] != 'ENG') && ($_POST['HIN'] != 'HIN') && ($_POST['MAR'] != 'MAR'))
{
$errors[ ] = 'Please check a category before submitting';
$ENG='';
$HIN='';
$MAR='';
}
}
if ($srclg=='HIN')
{
if ( ($_POST['ENG'] != 'ENG') && ($_POST['GUJ'] != 'GUJ') && ($_POST['MAR'] != 'MAR'))
{
$errors[ ] = 'Please check a category before submitting';
$ENG='';
$GUJ='';
$MAR='';
}
}
if ($srclg=='MAR')
{
if ( ($_POST['ENG'] != 'ENG') && ($_POST['GUJ'] != 'GUJ') && ($_POST['HIN'] != 'HIN'))
{
$errors[ ] = 'Please check a category before submitting';
$ENG='';
$GUJ='';
$HIN='';
}
}
return $errors;
return $ENG;
return $GUJ;
return $HIN;
return $MAR;
}
function process_form( ) {
echo '<p style="font-family:times; color:black; font-size:20px; text-align:center">Thank you for completing part II of the form, now please proceed to <a href="translationorder3.php">Part III</a>.</p>';
}
?>
User avatar
Grizzzzzzzzzz
Forum Contributor
Posts: 125
Joined: Wed Sep 02, 2009 8:51 am

Re: script 2 not running

Post by Grizzzzzzzzzz »

so....what's wrong?

whats not working?

what does it do?

what is it supposed to do?

what error message does it give?

what line does it throw the error on?

what solutions have you already tried to solve this?



additionally, don't suppose there is any risk of wrapping the whole thing in php code tags?
Post Reply