Jump to content

Recommended Posts

Hi Guys!

 

Im using cases to forward to a new stage of a contact/job application form I have created. So ive coded my page but ive when I ask my form to post to the next stage it does it but it doesn't work properly and Im really ready for going insane  ;D

I was hoping there would be someone kind enough to help me out by looking over my code and possibly spotting the error if possible.

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<link rel="stylesheet" type="text/css" HREF="contact-style.css">
<body> 
<?php
require("../includes/config.php");
include("processes-I.php");

$getid = $_GET[id];

$_SESSION["refid"] = $getid;
/* Stored id in a session! */

$job = $_SESSION["refid"];
?>
<div id="header"><div id="navbar"><? if(!$logged[username] && !$logged[level]){ ?><b><center>You are not currently logged in</center></b><? } elseif($logged[username] && $logged[level]){ ?> <? echo"$logged[username]"; ?> (<? echo"$logged[email]"; ?>)<div style="float: right; padding-right: 15px;">Logout</div><? } ?></div></div>
<div id="logo"></div>
<br><br><br><br><br>
<div id="container">
<table width="985" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="33px" background="images/greyforumtop.png" style="background-repeat: no-repeat; text-decoration: none;"><table width="965" border="0" cellspacing="0" cellpadding="0" style="color: #FFFFFF; font-size: 12px;">
                  <tr>
                    <td height="5"></td>
                  </tr>
                  <tr>

                    <td class="style1"><center><strong>Job Application <? if($_GET[stage] ==NULL OR !$_GET[stage]){ echo"Criteria"; }elseif($_GET[stage] =1){ echo"Stage $_GET[stage]"; }?></strong></center></td>
                  </tr>
              </table></td>
            </tr>

            <tr>
              <td background="images/forumbod.png" style="background-repeat: repeat-y;"><table width="985" border="0" cellspacing="0" style="padding-left: 2px;">
                  <tr>

                    <td width="17"> </td>
                    <td>
<tr>
<td width="985px" style="padding-left: 4px; padding-right: 3px;"><br>

<?php
switch ($_GET["stage"]){
default:

?>
<?
$find = mysql_query("SELECT * FROM applications where refc='$job' ORDER BY id ASC") or die (mysql_error()); //find the inputs from the table  
while ($row = mysql_fetch_array($find)){
?>
<img src="images/head_icon1.gif" align="left"> <font color=#336699 size=2><b><? echo"$row[jobtitle]"; ?> Criteria</b></font><br>&nbsp<font style="font-family: Verdana; font-size: 8pt;">Required Criteria!
<? } ?>
<br><br>
<div style="padding-left: 20px;"><img src="images/c_icon.gif"> Must have a developed understanding of moderation and administrative practices.<br>
<img src="images/c_icon.gif"> Must be able to record data and answer questions in sufficient detail.<br>
<img src="images/c_icon.gif"> Candidates are required to be fluent in English - verbalaly and written.<br>
<img src="images/c_icon.gif"> Must be able to stay calm and speak with heated visitors.<br><br>
</div><br>
<?
$find = mysql_query("SELECT * FROM applications where refc='$job' ORDER BY id ASC") or die (mysql_error()); //find the inputs from the table  
while ($row = mysql_fetch_array($find)){
?>
<img src="images/head_icon1.gif" align="left"> <font color=#336699 size=2><b><? echo"$row[jobtitle]"; ?> Criteria</b></font><br>&nbsp<font style="font-family: Verdana; font-size: 8pt;">Recommended Criteria!
<br><br>
<div style="padding-left: 20px;"><img src="images/c_icon.gif"> Developed Organisational Skills.<br>
<img src="images/c_icon.gif"> Ability to prioritise issues and work under pressure of deadlines.<br>
<img src="images/c_icon.gif"> Integrate new ideas and practices to the department.<br>
<img src="images/c_icon.gif"> Be comfortable with new projects and decisions by management.<br><br>
</div><br>
<img src="images/head_icon1.gif" align="left"> <font color=#336699 size=2><b>Duties of a <? echo"$row[jobtitle]"; ?></b></font><br>&nbsp<font style="font-family: Verdana; font-size: 8pt;">What you are expected to do!
<br><br><? } ?>
<div style="padding-left: 20px;"><img src="images/c_icon.gif"> Answering assistance calls.<br>
<img src="images/c_icon.gif"> Observing the forum ensuring forum rules are being followed.<br>
<img src="images/c_icon.gif"> Editing the visibility of forum features and profiles to rule breakers.<br>
<img src="images/c_icon.gif"> Assisting in the development of the community<br>
<img src="images/c_icon.gif"> Offering informaton and safety advice to members.<br>
<br>
</div>
<?
$ip = $_SERVER['REMOTE_ADDR'];
if($logged[username] && $logged[level]){  
?>
<form method="post" action="?stage=2">
<div style="padding-left: 20px;">
			    <input type="hidden" name="IP" id="IP" value="<? echo"$ip"; ?>"/>
                                    <input type="hidden" name="id" id="id" value="<? echo"$getid"; ?>"/>
			    </label>
			    <label>
			    <input type="submit" name="button" id="button" value="Continue" />
		      </label>
</form>
</div>
<? }if(!$logged[username] && !$logged[level]){?>
<div style="padding-left: 20px;">
<b>You must be logged in to apply for this position.</b>
</div>
<? } ?>
<? 
B;

break; 

case 2: 

if(!$_POST["IP"] || $_POST["IP"] == ""){
echo "<script>window.location = '?stage=1';</script>";
exit;
}

$username = $_POST["IP"];
/* Clean! */
$username = clean($username, "no_SQL");

$_SESSION["username"] = $username;
/* Stored username in a session! */

$getid = $_POST["id"];

$_SESSION["refid"] = $getid;
/* Stored id in a session! */

$job = $_SESSION["refid"];

$find2 = mysql_query("SELECT * FROM applications where refc='$job' ORDER BY id ASC") or die (mysql_error()); //find the inputs from the table  
while ($row2 = mysql_fetch_array($find2)){
?>
<form method="post" action="?stage=3"><table border="0" cellspacing="0" cellpadding="0" class="ihead">

<img src="images/head_icon1.gif" align="left"> <font color=#336699 size=2><b>Description of a <? echo"$row2[jobtitle]"; ?></b></font><br>&nbsp<font style="font-family: Verdana; font-size: 8pt;">Short introduction!
<br><br>
<div style="padding-left: 30px; padding-right: 13px;">
<? echo"$row2[jobdesc]"; ?>
</div>
<br><br>
<img src="images/info_head.gif" align="left"> <font color=#336699 size=2><b>Application Tips</b></font><br>&nbsp<font style="font-family: Verdana; font-size: 8pt;">Some tips to help you out!
<br><br>
<div style="padding-left: 20px;">
<img src="images/app++.gif"> Always refer to the question being asked and answer it in full detail.<br>
<img src="images/app+.gif"> Always be positive in your application.<br>
<img src="images/app++.gif"> In the "Experience" field, you may use real life examples of team work etc.<br>
<img src="images/app+.gif"> <b>Reminder:</b> If you cannot complete a certain field please ensure to put <b>N/A</b> in it.<br>

</div>
<br><br>
<img src="images/head_icon1.gif" align="left"> <font color=#336699 size=2><b>Application for <? echo"$row2[jobtitle]"; ?></b></font><br>&nbsp<font style="font-family: Verdana; font-size: 8pt;">Duration: <i>30mins</i>!
<br><br>
<div style="padding-left: 30px; padding-right: 13px;">
<b>What can you bring to the department?</b><br>
<TEXTAREA NAME="field1" COLS=70 ROWS=9></TEXTAREA>
<br><br>
<b>Why should we pick you, apposed to other candidates?</b><br>
<TEXTAREA NAME="field2" COLS=70 ROWS=9></TEXTAREA>
<br><br>
<b>What previous experience of this field do you have?</b><br>
<TEXTAREA NAME="field3" COLS=70 ROWS=7></TEXTAREA>
<br><br>
<b>Explain yourself in 4 different ways and explain why?<br></b>
<TEXTAREA NAME="field4" COLS=70 ROWS=7></TEXTAREA>
			    <br />
			    <br />
			    <input type="submit" name="button" id="button" value="Submit Application" />
</div>
<?
}				  
if($_GET["error"] == "invalid_email")
{
			  
echo "<b>Please double check the entered fields</b>";
			  
}
echo <<<B
			</div>			</td>
	</tr>
</table>
</form>
B;

break;

case 3:

/* Email stage! */

if(!$_POST["field1"] || !$_POST["field2"] || !$_POST["field3"] || !$_POST["field4"])
{
echo "<strong>You missed a field!</strong><br /><br />Please go <a href=\"javascript:history.back(-1)\">back</a> and fix this";
}
else
{ 

$field1a = $_POST["field1"];
$field1 = clean($field1a, "no_SQL");
$_SESSION["field1"] = $field1;

$field2a = $_POST["field2"];
$field2 = clean($field2a, "no_SQL");
$_SESSION["field2"] = $field2;

$field3a = $_POST["field3"];
$field3 = clean($field3a, "no_SQL");
$_SESSION["field3"] = $field3;

$field4a = $_POST["field4"];
$field4 = clean($field4a, "no_SQL");
$_SESSION["field4"] = $field4;

        $ulog = $logged[username];
$ip = $_SERVER['REMOTE_ADDR'];
$afield1 = clean($_SESSION["field1"], "sql");
$afeild2 = clean($_SESSION["field2"], "sql");
$afeild3 = clean($_SESSION["field3"], "sql");
$afeild4 = clean($_SESSION["field4"], "sql");
$date = date("d/m/Y"); 
$dat = time() + 3600;
$today2 = date("g:i a", $dat);


$query = "INSERT INTO `applicationview` (`username`, `ip`, `date`, `time`, `field1`, `field2`, `field3`, `field4`, `status`) VALUES ('".$ulog."', '".$ip."', '".$date."', '".$today2."', '".$field1."', '".$field2."', '".$field3."', '".$field4."', 'unread')";

$query_do = mysql_query($query) or die("Could not perform SQL Action, Error: ".mysql_error());
/* We have set the applications sessions */
echo <<<B
<form method="post" action="?stage=4" name="form" id="form"><table border="0" cellspacing="0" cellpadding="0" class="ihead">

<tr>
	<td class="icon"><img src="images/3.gif" alt=" " width="47" height="37" /></td>
	<td class="text">
		<h2>enter your message</h2>

	</td>

	</tr>
</table>
<br>

<table border="0" cellspacing="0" cellpadding="0" class="content-table">

	<tr>
		<td valign="middle" align="left" style="width: 300px;">
			<div class="iinfodiv">
				<strong>Message:</strong><br>
			    <label>
			    <textarea name="message" id="message" cols="50" rows="5" onClick="javascript:if(document.form.message.value == 'Enter message here...') { document.form.message.value = '' }">Enter message here...</textarea>
			    </label>
			    <br />
			    <br />
			    <label>
			    <input type="submit" name="button" id="button" value="Next" />
		      </label>
			</div>			</td>
	</tr>
</table>
</form>
B;

break;
}
unset($_SESSION["field1"]);
unset($_SESSION["field2"]);
unset($_SESSION["field3"]);
unset($_SESSION["field4"]);

}
?>
</td>
</tr>
</table><br></td>

            </tr>
            <tr>
              <td><img src="images/forumbot.png" width="985" height="15" /></td>

            </tr>
          </table></td></center>
<br /><br />
</div>

 

Any help would be most appreciated.

Thank you

Link to comment
https://forums.phpfreaks.com/topic/201873-php-case-problem/
Share on other sites

<?php will always work as an opening php tag.

 

<? won't always work and causes huge amounts of wasted time chasing down php.ini settings to get it to work when you switch servers or someone updates the server you are on and it gets turned off.

 

Be consistent and save time by always just using the <?php tag.

Link to comment
https://forums.phpfreaks.com/topic/201873-php-case-problem/#findComment-1058920
Share on other sites

Well the top of my code gives the PHP get $_GET[stage] there is in total 3 stages -

 

Default : Criteria Page

Stage 2 : Application Page

Stage 3 : Thank you for submitting page

 

Both the default and Stage 2 have forms on them, the variables entered on each forum is saved via sessions and sent at the end of stage 2.

 

From my code you can see the forms action progresses to the next stage (e.g. Stage one form submission leads to stage 2 and so on)

 

My current problem is my Default page acts as stage 1 and on form submission goes to stage 2 although it does not preview the application! it previews another criteria page for another job (I know why it is doing this I just dont know what is making it)

 

I have two applications in my database:

1 - Moderation

2 - Community Publisher

 

If you see what it is doing now, it is changing the row ID in the SQL  to match ID of the stage - this means I can never get past stage 1. If I do get past stage 1 it and it goes to stage 2 it wont show the application but the criteria page still.

 

I hope I have not confused those of you willing to help

Sorry and Thanks!

Link to comment
https://forums.phpfreaks.com/topic/201873-php-case-problem/#findComment-1058931
Share on other sites

Given that your code is using $_SESSION variables and it has HTML (the doctype tag through to the body tag) before any possible session_start() in your code, the session is probably not working.

 

Are you learning php, developing php code, and debugging php code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that php would help you by reporting and displaying all the errors it detects?

Link to comment
https://forums.phpfreaks.com/topic/201873-php-case-problem/#findComment-1059099
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.