Jump to content

vinsux

Members
  • Posts

    45
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

vinsux's Achievements

Member

Member (2/5)

0

Reputation

  1. //some php sql codes echo "<form action='survey.php' method='POST'>"; echo "<td class = name> <input type='checkbox' name='vote[]' value='$sql_row[name]' id='$sql_row[id]'>".$name."</td>"; echo "</tr>"; } } echo "<tr><td class = btn><button type='submit' name='btnSurvey'>Vote</button></td> </tr></form>"; echo "<form action='viewsurvey.php' method='POST'>"; echo "<tr><td class = btn><button type='submit' name='btnResult'>Results</button></td> </tr></form>"; echo "</table>"; //echo " <tr><td><button type='submit' name='btnSurvey'>Vote</button></td> </tr></form>"; } mysql_close(); include('connect.php'); $result = mysql_query("SELECT * from candidates"); //adding only one candidate if(!empty($_POST['vote'])) { foreach($_POST['vote'] as $check) { // echo $check; mysql_query("UPDATE candidates SET votes = votes + 1 WHERE name = '$check'"); header("Location: viewsurvey.php"); exit(); } } // some codes i found a bug on my work, my work is about survey, users will choose from 20+ candidates and they need to select only 12.. i used check box for user to select more than one candidate to vote, i want to set it until 12 but i can only add one vote on the candidate even i checked (or vote) more than one. help please..
  2. gotcha!.. thanks a lot bro and also PsyCho...
  3. ^ that sample code is what i'm looking for, but i tried that code and it's not working... sorry for my bad english..
  4. i tried this one //sql parts $percentage = $votes / 100 * $total; echo "<td class = result style='width:echo $percentage;%'>".$votes."</td>"; but it's not working
  5. i already found out the solution on counting the values, i only need the solution on how to set the width of a table from the value from the database..
  6. hi there, i just wanna ask a question.. i'm making a poll using php right now.. may i ask if it's possible to set the width of a <td> in a table from the values from the database?.. also how can i count the total value of numbers in a database. in my database, i have a number of votes from different names, how can i count them all? because i need it to get the percentage of the votes.. please help me thanks and god bless..
  7. ^ ^ So even there's no internet?.. if i access that localhost sever.. i can access the website.. and the changes i've been made in the localhost can change in the online too???... Is there a tutorial on what to do on that one?? i can't find on the internet.. i just badly need it.. tnxxxxx
  8. Is it possible to have a localhost server in your online website... so that even there's no internet.. you can still access the website and if you use the localhost server, the same registered users in online can use it?.. and you can register users too??.. I'm using cpanel on my website.... is it applicable???
  9. ^ ^ tnx sir.. i got the logic and the code for that.. but how about this one?? the content is in one declaration of if else.. so hard... There's still a header error.. i can't understand the logic on this code.. on how the header will be placed.. <?php session_start(); ?> <!DOCTYPE html> <html lang="en"> <?php include('include/header.php'); ?> <body> <?php include('include/container.php'); ?> <?php include('include/left.php'); ?> <?php include('include/panelstud.php'); ?> <div id="right"> <h3>Student Change Password</h3> <?php if(isset($_SESSION['id'])) { $username = $_SESSION['id']; if (isset($_POST['submit'])) { if(!$_POST['oldpassword'] | !$_POST['newpassword'] | !$_POST['repeatnewpassword']) { die('You did not fill in a required field...<a href=studchangepass.php>Back</a>'); } if (strlen($_POST['repeatnewpassword'])>32||strlen($_POST['repeatnewpassword'])<6) { die("<br /> *Password must be between 6 and 32 characters long... <a href=studchangepass.php>[back]</a>"); } $oldpassword = md5($_POST['oldpassword']); $newpassword= md5($_POST['newpassword']); $repeatnewpassword = md5($_POST['repeatnewpassword']); $connect = mysql_connect("localhost", "root","") or die ("couldnt connect to mysql data base "); mysql_select_db("ocmpq_login") or die("couldnt find db") ; $queryget = mysql_query("SELECT password FROM students WHERE username ='$username'") or die("query didnt work"); $row=mysql_fetch_assoc($queryget); $oldpassworddb=$row['password']; if ($oldpassword==$oldpassworddb) { if ($newpassword==$repeatnewpassword) { $querychange = mysql_query("UPDATE students SET password='$newpassword' WHERE username='$username'"); header("location:logout.php"); } else die ("New Password did not match! <a href=studchangepass.php>[try again]</a>"); } else die ("Your old password input did not match in your old pass! <a href=studchangepass.php>[try again]</a>"); } else echo " <form action='studchangepass.php' method='POST'> <table border = 0 align = center> <tr> <th width = 35%>Old password:</center></th><th><input type='password' name='oldpassword'></th></tr> <th width = 35%>New password:</th><th><input type='password' name='newpassword'><p></th></tr> <th width = 35%>Repeat new password:</th><th><input type='password' name='repeatnewpassword'></th></tr> <th colspan = 2 align = right><br><input type='submit' name='submit' value='change password' style='width: 150px; height: 30px'></th> </tr> </table> </form> "; } else die ("You must be logged in to change the password") ?> </div> </div> </div> <?php include('include/footer.php'); ?> </body> </html>
  10. pls. help on my header... i tried to put up the the php code first but still.. it gives an error... i dont know what to do.. i'm sick of this error.. please help me to rearrange the right code to fix the error.. tnx in advance <?php session_start(); ?> <!DOCTYPE html> <html lang="en"> <?php include('include/header.php'); ?> <body> <?php include('include/fcontainer.php'); ?> <?php include('include/facultyleft.php'); ?> <?php include('include/panelfaculty.php'); ?> <div id="right"> <h3>Your Information</h3> <?php if(isset($_GET['delete'])) { $con = mysql_connect("localhost", "secret","secret"); if(!$con) { die("could not connect to server".mysql_error()); } mysql_select_db("ocmpq_login", $con); $result = mysql_query("SELECT * from faculty where username='$_GET[delete]'"); while($row = mysql_fetch_array($result)) { $sn = $row['username']; $nl = $row['namelast']; $nf = $row['namefirst']; $nm = $row['namemi']; $rm = "$row[namelast], $row[namefirst] has been removed from the site"; echo "<script type='text/javascript'>alert('$rm')</script>"; mysql_query("DELETE FROM faculty where username ='$_GET[delete]'"); header("Location: logout.php"); } mysql_close($con); } if(isset($_SESSION['id'])) { $username = $_SESSION['id']; $con = mysql_connect("localhost", "secret","secret"); if(!$con) {die("could not connect to server".mysql_error());} mysql_select_db("ocmpq_login", $con); $result = mysql_query("SELECT * from faculty WHERE username = '$username'"); $sql_num=mysql_num_rows($result); if($row = mysql_num_rows($result) == 0) { echo "There are no registered faculty yet<br><br>"; $name=$row["username"]; $class=$row["namelast"] .$row["namefirst"]; } else { while($sql_row = mysql_fetch_array($result)) { $name=$sql_row["username"]; $class=ucfirst($sql_row["namelast"]). ', ' .ucfirst($sql_row["namefirst"]). ' ' .ucfirst($sql_row["namemi"]); $gender=$sql_row["gender"]; $email=$sql_row["email"]; $course= $sql_row["course"]; $pass= $sql_row["password"]; echo "<table border = 0 style='background-image:url(images/test.png); cellpadding='0px'>"; echo "The Complete Information of <b>$class</b>."; echo "<br><br>"; echo "<hr>"; echo "<th width = 10%><b><br><br> Staff ID:</b> </th>"; echo "<th width = 70%><br><br>" .$name."</th></tr>"; echo "<br><br>"; echo "<th><b> Name:</b> </th>"; echo "<th>" .$class."</th></tr>"; echo "<th><b> Gender:</b> </th>"; echo "<th>" .$gender."</th></tr>"; echo "<th><b> Email:</b> </th>"; echo "<th>" .$email."<br><br><br><br></th></tr>"; echo "<th colspan=2 align=center><br> <a href=javascript:confirmDelete('?delete=$sql_row[username]')><img src='images/deactivate.png'></a></th>"; echo "</table>"; echo "<br><br><br><hr><br><br>"; } } } mysql_close(); ?> </div> </div> </div> <footer> <div id="privacy"> thesis Project ? 2012 Privacy Policy</a><br /> </div> </footer> </div> </body></html>
  11. hi again... i need a help again,.. i need an error trapping for my code.. if the selected type of account is faculty, the default course in the drop down menu must be "na" if the selected type of account is student, then it cannot accept the "na" value because he's a student... i'm tired finding a solution and researching, please help me again.. tnx in advance.. <?php mysql_connect("localhost", "root","")or die(mysql_error()); mysql_select_db("login") or die(mysql_error()); $errors=""; $message=""; if (isset($_POST['submit'])) { if (empty($errors)){ $_POST['type'] = mysql_real_escape_string($_POST['type']); $_POST['course'] = mysql_real_escape_string($_POST['course']); $check = "SELECT STATEMENT"; $result = mysql_query($check) or die(mysql_error()); $insert = "INSERT STATEMENT"; $add_member = mysql_query($insert) or die(mysql_error()); if (mysql_affected_rows()==1){ echo '<script type="text/javascript">alert(" '.$_POST['namelast'].', '.$_POST['namefirst'].' has been Registered!")</script>'; $message .= "<br><br><h1>Registered</h1> <br><br><p>Thank you, the user ".$_POST['namelast']." registered..</p> <p><a href = 'faculty.php'>[Click here]</a> to go back to home page or <a href = 'register.php'>[click here]</a> to register again<br> <br>"; } } ?> <?php if (!empty($message)){ echo "$message"; }else{ if (!empty($errors)){ echo "<br />$errors";} ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table border="0"> <tr> <th>Type of Account:</th> <th colspan="3"> <select name= "type"> <?php $atype = array( "students" => "Student", "faculty" => "Teacher" ); foreach($atype as $tkey => $tvalue){ $selected_type = (isset($_POST['type']) && $_POST['type']==$tkey ? 'selected="selected"' : ''); echo "<option value=\"$tkey\" $selected_type>$tvalue</option>\r"; } ?> </select> </th> </tr> <tr> <th> *Course:</th> <th colspan="3"> <select name= "course"> <?php $courses = array( "na" => "---N.A.----", "bscs" => "B.S. Computer Science", "bsit" => "B.S. Information Technology", "bsba" => "B.S. Business Administration" ); foreach($courses as $key => $value){ $selected_course = (isset($_POST['course']) && $_POST['course']==$key ? 'selected="selected"' : ''); echo "<option value=\"$key\" $selected_course>$value</option>\r"; } ?> </select> </th> </tr> </table> </form>
  12. wwaaa...... change your pass change your pass change your pass change your pass
  13. vinsux

    HELPPP

    ok sir.. Tnx For the HELP again.. OffTopic: hahaha coz i'm playing international online games and i always encounter that word.. :D :D
  14. vinsux

    HELPPP

    ok sir.. i'm sorry i'm not good in english.. but suddenly, i dunno what happened or what i have done but it's already fixed.. :shrug: but here's what i had encountered last night... my website is already uploaded in webhost.. i have an upload and download script and it's already running.. my problem is that, when i upload 1-3mb file.. it works fine.. but when i upload more than 6mb.. it prompts an error says something like "max_size is blah blah blah" based on my research, i think the problem is on the php.ini so i need to upload my php.ini file from localhost to my webhost server.. because when i ran the script on localhost.. it doesn't prompt any errors
  15. vinsux

    HELPPP

    ^ ^ Where's the .htaccess file sir?? i will make a notepad??
×
×
  • 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.