Advertisement

04.24.2008 at 05:44PM PDT, ID: 23352372
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

post variable refresh issue trying to use header redirect but my code has prints before the redirect?

Asked by tyweed420 in PHP Scripting Language, Miscellaneous Web Development, WebApplications

Tags:

So, I have done my research and it appears that the best action for me to take is a header redirect to the same page after submit button is set. Problem is i have code before i can do the redirect that have html/print to console. I cannot figure out how to get the header at the top before the html please help me reorganize this code to get it to work.

Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
<?php
 session_start();
 $_SESSION['newform'] = 1;
?>
<html>
<head>
<title> You Bet Your Ass!</title>
<link rel="stylesheet" type="text/css"
href="mystyle.css" />
<script  type="text/javascript">
function validateForm(form)
{
 
   var ar_errors = new Array();
   var j=0;
  for(var i=0; i < form.elements.length;i++)
  {
    if(form.elements[i].type == "text" || form.elements[i].type == "password" )
    {
		 var value = trim(form.elements[i].value);
		 if(value == "")
		 {
		   ar_errors[j] = form.elements[i].name;
		   j++;
		 }
    }
 
  }
 
  if(ar_errors.length > 0)
  {
      var errorString="\n";
	  for(var i=0; i < ar_errors.length;i++)
	  {
	    errorString += ar_errors[i] + "\n";
	  }
    alert("You forgot to enter in the fields for: " + errorString );
    return false;
  }
  else
  {
    return true;
  }
 
 
}
 
function trim(s)
{
    var l=0; var r=s.length -1;
    while(l < s.length && s[l] == ' ')
    {     l++; }
    while(r > l && s[r] == ' ')
    {     r-=1;     }
    return s.substring(l, r+1);
}
 
 
</script>
</head>
<body>
<table width="100%">
<tr>
<td> <img src="logo.jpg" alt="You bet your ass logo" width="600" height="150"> </td>
</tr>
<tr>
<td>
<!-------START BODY-->
 
 
 
 <?php
 
 
  if(isset($_POST['submit']) )
  {
         include("dbconnect.php");
         include("Globals.php");
 
 		 $email = trim($_POST['email']);
 		 $password = trim($_POST['password']);
 
 		 $query ="SELECT * FROM users  WHERE email  = '$email' AND password = '$password'";
 
     	 $r = mysql_query ($query);
 
         if(!$r)//bad sql command
         {
 
         	printSqlError();
         	printLogin();
 
          }
          //check for error input empty password or userID
          else if( $email == "" || $password == "")
           {
             print "<p class='warning'> You forgot to enter in either your email or password.</p>";
                printLogin();
 
  		  }
           //check for error input incorrect password or userID
           else if(mysql_num_rows($r) == 1)
           {
 
                         $row = mysql_fetch_array($r);
                         $_SESSION['name'] = $row['username'];
 			             $_SESSION['email'] = $email;
 			             $_SESSION['password'] = $password;
 
 
 			 	         echo "<script language=javascript>window.location.href=\"main.php\"</script>";
 
 
 
 			  }
 			  else
 			  {
 
   			     print "<p class='warning'> Incorrect Login or Password!</p>";
                  printLogin();
 			  }
 
 
 
           }
           else
           {
             printLogin();
           }
 
 
 
 function printLogin()
 {
print <<< HTMLBLOCK
              <center>
              <form action ="Login.php" onSubmit="return validateForm(this)" method = "post">
             <table>
             <tr>
             <td align = left>
             <fieldset>
             <legend> Login</legend>
 		     <label for="email">Email :</label>
  		     <br/>
  		     <input type = 'text' name = 'email' id="email" size = '40'/>
  		     <br/>
 		     <label for="password">Password :</label>
  		     <br/>
  		     <input type = 'password' name = 'password' id="password"  size = '25'/>
  		     <br/> <br/>
  		     <input type = 'submit' name = 'submit' value = 'submit'/>
  		     <br/> <br/>
  		     <a href='LostPassword.html'> Forgot Password?</a>
  		     <br/>
  		     </fieldset>
  		     </td>
      		 </tr>
  		     </table>
  		     <br>
  		     <br>
HTMLBLOCK;
 
 
 }
 
 
 
 
 
 ?>
 
 
 </form>
 
 
 
 
 
<!--------END BODY---------->
 
<!------------------- ENDING MAIN TABLE FOR PAGE-------------->
</td>
</tr>
</table>
 
</body>
</html>
[+][-]04.25.2008 at 02:03AM PDT, ID: 21437878

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Miscellaneous Web Development, WebApplications
Tags: php
Sign Up Now!
Solution Provided By: MatthewP
Participating Experts: 1
Solution Grade: A
 
 
[+][-]10.30.2008 at 04:31AM PDT, ID: 22839634

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11.07.2008 at 05:00PM PST, ID: 22909805

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628