Problem with if condition using forms.
Posted: Thu Apr 15, 2004 6:32 pm
Manio wrote:Hi, I am new to this forum and to PHP. I have done some basic to intermediate level coding using Mysql and PHP. I was having a trouble with one of the codes, i hope you could help.
Following is the code of my main file after the authentication has been done.
Code: Select all
<?php
session_start();
$view = 1;
$globalid = $_SESSION["globalid"];
$link = mysql_connect('localhost');
if (!$link) {
die('Not connected : ' . mysql_error());
}
$db_selected = mysql_select_db('student', $link);
if (!$db_selected) {
die ('Can''t use student : ' . mysql_error());
}
if ($view == 1) {
$query1 = "select bio.firstname as firstname, bio.lastname as lastname, bio.program as program,
bio.focus as focus, bio.semester as semester, bio.year as year from bio
where bio.id = $globalid";
$result1 = mysql_query($query1);
$basicinfo = mysql_fetch_array($result1);
mysql_free_result($result1);
$query2 = "select alerts as alerts from alerts where alerts.id = 3";
$result2 = mysql_query($query2);
$alertsinfo = mysql_fetch_array($result2);
mysql_free_result($result2);
$view=2;
require "studentserv_controller_view.php";
}
if ($_POST['submit'] == 'course_planner') {
$redirect_to = "course_controller.php";
require "redirect.php"; }
$query1 = "select courses.courseid as courseid, courses.coursename as coursename, courses.instructorname as instructor,
courses.semester as sem from courses where courses.semester = 'fall'";
$result1 = mysql_query($query1);
$num_rows = mysql_num_rows($result1);
$i=1;
mysql_data_seek($result1, 0);
while ($row = mysql_fetch_array($result1) AND $i<$num_rows+1){
$tmp1 = "courseid$i";
${$tmp1}= $row['courseid'];
$tmp2 = "coursename$i";
${$tmp2} = $row['coursename'];
$tmp3 = "instructor$i";
${$tmp3} = $row['instructor'];
$tmp4 = "sem$i";
${$tmp4} = $row['sem'];
$i++; }
require "studentserv_controller_view.php";
?>Manio wrote: The first if condition is working as wanted, but from the page student_controller_view.php the submit button which activates the second if condition seems to be non -functional. Here is the HTML of the student_controller_view.php.
Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Student services main</title>
<style type="text/css">
<!--
.style1 {
font-family: Arial, Helvetica, sans-serif;
font-size: 36px;
}
.style2 {
color: #008000;
font-weight: bold;
font-family: Georgia, "Times New Roman", Times, serif;
}
.style3 {color: #804040}
body {
background-color: #000000;
}
body,td,th {
color: #FFFFFF;
}
.style4 {
color: #FFFFFF;
font-size: larger;
}
.style5 {font-family: Georgia, "Times New Roman", Times, serif; color: #008000;}
-->
</style>
</head>
<body>
<form name="form1" method="post" action="studentserv_controller.php">
<p align="left" class="style1"> <span class="style2"><img src="uab.JPG" width="168" height="58" align="left"> </span><span class="style5"><span class="style4">Student Services</span></span> </p>
<hr>
<p>
<input type="submit" name="course_planner" value="Course Planner">
</p>
<div id="Layer1" style="position:absolute; width:474px; height:118px; z-index:1; left: 140px; top: 121px; background-color: #FFFFFF; layer-background-color: #FFFFFF; border: 1px none #000000;">
<textarea name="textarea" cols="65" rows="6"><?php print "$basicinfo[firstname] $basicinfo[lastname] \n$basicinfo[program] $basicinfo[focus] \n$basicinfo[semester] $basicinfo[year]" ?></textarea>
</div>
<p>
<input type="Submit" name="grades" value="Grades">
</p>
<p>
<input type="Submit" name="payment" value="Payment">
</p>
<p>
<input type="Submit" name="logout" value="logout">
</p>
<div id="Layer2" style="position:absolute; width:626px; height:343px; z-index:2; left: 142px; top: 272px; visibility: visible;">
<textarea name="textarea" cols="100" rows="20"><?php print "$courseid1 $courseid2 $courseid3" ?></textarea>
<? //$coursename[2] \n\n $instruct[3] \n\n $sem $num_rows" ?>
<?php print "$num_rows $courseid5 $courseid0 $courseid3 $dummy $tmp1" ?>
</form>
</div>
<p> </p>
<p class="style3">
</p>
<p align="center"> </p>
<p> </p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><img src="ncaab_uabblazers.jpg" width="94" height="72" align="left"></p>
</body>
</html>Manio wrote:A little shabby but i hope you could help?Thanks in advance.