Jump to content

Ell20

Members
  • Posts

    337
  • Joined

  • Last visited

    Never

Everything posted by Ell20

  1. It dosent seem to have had any effect and its working fine?
  2. Cheers guys, I just removed "$club_id == $OTHER_CLUB_ID ? $sel = 'SELECTED' : $sel = '';" as I was using a drop down box from a previous page and noticed I didnt need that for this one. Thanks for your help
  3. It actually changed the username to Admin that you selected now, cheers! I still think its weird that when you first go to the page it says the bottom user in the list rather than "Select Member"?
  4. Im nearly there, however something is not quiet right with the drop down box as the initial value displayed should be Select Member - disabled however its not, it displays the last member in the list. The code is working properly however it dosent matter which user you select from the list, it changes the bottom user in the list to Admin. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="member"><option value="" selected disabled>Select Member</option> <?php $sql = "SELECT * FROM users WHERE club_id = '$id' AND member_type = 'Member'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $user_id = $row["user_id"]; $username = $row["username"]; $club_id == $OTHER_CLUB_ID ? $sel = 'SELECTED' : $sel = ''; ?> <option value="<?php echo $user_id ?>" <?php echo $sel ?>><?php echo $username ?></option> <?php } ?> </select> </td> </tr> <tr> <td align="center"> <input name="submit" value="Convert Member To Admin" type="submit" /> </form> <?php if (isset($_POST['submit'])) { $update = "UPDATE users SET member_type='Admin' where user_id='$user_id'" or die(mysql_error()); mysql_query($update) or die(mysql_error()); echo '<center><h3>Member converted to Admin</h3></center>'; } ?>
  5. I have a table called users which has a field called member_type. The member_type is either 'Member' or 'Admin' However im unsure on how I update the member_type for member selected in the drop down box? Cheers
  6. Hey guys, Im trying to add an Admin feature where the admin can select a member to convert to an admin. I have created a dynamic drop down box which takes all the possible members linked to the particular club for the admin to select from however I am unsure on how to then change the value in the database for the selected user. Here is what I have so far: <?php if (isset($_POST['submit'])) { //Query to change the select user into Admin $query = "INSERT INTO users (member_type) VALUES ('Admin')"; $result = @mysql_query ($query); if ($result) { echo '<h3></h3>'; } } ?> //Dynamic drop down box <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <select name="member"><option value="">Select Member</option> <?php $sql = "SELECT * FROM users WHERE club_id = '$id' AND member_type = 'Member'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $user_id = $row["user_id"]; $username = $row["username"]; $club_id == $OTHER_CLUB_ID ? $sel = 'SELECTED' : $sel = ''; ?> <option value="<?php echo $user_id ?>" <?php echo $sel ?>><?php echo $username ?></option> <?php } ?> </select> Appreciate any help Elliot
  7. It should be ok because the actual code reads: <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Its working ok for now.
  8. Yeah its on the same level, that page seems to be working ok at the moment
  9. Scrap that, I forgot I was using a webhost, I needed go back to the starting domain for the changes to take place properly. I just remove / from "/main.php" and it seems to be working now. Cheers
  10. Not working at all now, when I log in it goes to http://index.php I have even changed the code back and its still not made any difference Grr
  11. Having logged in, the site isnt functioning as it was when I was using it as local host. http://mysport.x10hosting.com Username: Test Password: Test When I add news on the news page and press Create News it takes me to the following page: http://news.php/, how comes it isnt adding in the correct address? Also on all the pages the address has to // e.g http://mysport.x10hosting.com//news.php Any help is very much appreciated Elliot
  12. I seem to have it working now, I increased the length of the password to 50 characters in the database and created a new account. Is there a reason why the password field has a * at the start in the database for accounts registered using the webhost: "*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29" Also is there a reason why accounts that I have previously set up from the local host dont work on the web host when I simply export/imported the database from the local host to the web host? Cheers for your help
  13. Hey, I decided to transfer my site onto a web host so that I can show people my progress etc. I have uploaded all the files and the database but when I log in it says that the username and password do not match. In an attempt to solve this I registered a new account instead of using one from when I was using it on the local host but this didnt work either. I dont see how it can be a database connect problem as I managed to create a new account, which successfully stored into the databse <?php require_once ('includes/errors.inc'); $page_title = 'MySport'; include ('includes/header.html'); if (isset($_SESSION['user_id'])) { header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/main.php"); ob_end_clean(); exit(); } else { if (isset($_POST['submit'])) { require_once ('mysql_connect.php'); /* Check username is entered */ if (empty($_POST['username'])) { $u = FALSE; echo '<p><font color="red" size="+1">You forgot to enter your username!</font></p>'; } else { $u = escape_data($_POST['username']); } /* Check password is entered */ if (empty($_POST['password'])) { $p = FALSE; echo '<p><font color ="red" size="+1">You forgot to enter your password!</font></p>'; } else { $p = escape_data($_POST['password']); } /* If username and password entered query database to check they match in database */ if ($u && $p) { $query = "SELECT user_id, club_id FROM users WHERE username='$u' AND password=PASSWORD('$p')"; $result = @mysql_query($query); $row = mysql_fetch_array ($result, MYSQL_NUM); /* If they match create session */ if ($row) { $_SESSION['user_id']=$row[0]; $_SESSION['club_id']=$row[1]; ob_end_clean(); /* Redirect to main.php when logged in */ header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/main.php"); exit(); } else { echo '<p><font color="red" size="+1">The username and password do not match</font></p>'; } mysql_close(); } else { echo '<p><font color="red" size="+1">Please try again</font</p>'; } } } ?> <br /> <br /> <table width="70%" align="center" border="0"> <tr> <td width="17.5%" align="center"> <a href="index.php"><img border="0" src="images/home.jpg" width="200" height="30"></a> </td> <td width="17.5%" align="center"> <a href="register.php"><img border="0" src="images/register.jpg" width="200" height="30"></a> </td> <td width="17.5%" align="center"> <a href="registermember.php"><img border="0" src="images/registermember.jpg" width="200" height="30"></a> </td> <td width="17.5%" align="center"> <a href="forgot_password.php"><img border="0" src="images/forgotpassword.jpg" width="200" height="30"></a> </td> </tr> </table> <br /> <br /> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <form action="" method="post" name="form2" id="form2"> <table width="50%" align="center" cellspacing="0" border="0" class="game"> <tr> <th width="100%" colspan=3 align="center">Member Login Guest Login</th> </tr> <tr> <td width="33%">Username: <input type="text" name="username" size="20" maxlength="20" value="<?php if(isset($_POST['username'])) echo $_POST['username']; ?>"/></td> <td width="33%" align="center" rowspan="2"><select name="clubdrop"><option value="">Select Your Club</option> <?php require_once ('mysql_connect.php'); $sql = "SELECT * FROM club"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)){ $club_id = $row["club_id"]; $clubName = $row["clubn"]; $club_id == $OTHER_CLUB_ID ? $sel = 'SELECTED' : $sel = ''; ?> <option value="<?php echo $club_id ?>" <?php echo $sel ?>><?php echo $clubName ?></option> <?php } ?> The error I get is: Username and password do not match Thanks for any help
  14. Hey, I have been working on my website using a local host. I decided that I wanted to move it over to a web host, however for the time being I didn't want to pay for it. I have located a free one and uploaded all the files and database. However when I log in I get the following error: "Fatal error: Call to undefined function stripeslashes() in /home/mysport/public_html/mysql_connect.php on line 38" This error never occurred when I was working on the site from my PC. Is this an error to do with the web host blocking something or is there genuinely an error in my code? Cheers for any help
  15. Cheers guys, worked out needed the == when I got the parse error
  16. Hey, Im attempting to create an OR statement so that only certain users will be able to see a certain option. Here is my code: if ($webtype == 'Cricket' || 'Football'){?> - Tennis users can still see the option - not working! I have also tried: if ($webtype == 'Cricket' | 'Football'){?> -Works as I want for Cricket (option visable) and Tennis (option not visable), however you cant see the option if Football Am I doing this wrong? Cheers Elliot
  17. Thanks for your help, spot on as usual! Elliot
  18. Hey guys, Im trying to display some information in a while loop however one of the bits of data is optional so I dont want the heading to be displayed if there is no data in the variable. Here is my code at the moment but it dosent appear to be working: <?php if(isset($row['description'])) { echo "<b>Team Description: </b>"; echo $row['description']; echo "<br>"; } ?> Thanks for any help
  19. Thats a good point, I hadnt thought of that, is there anyway I could add something like: if($team_name == ""){ You must enter a team name} Cheers
  20. Done it I was just closing the if statement in the wrong place: <?php if (isset($_POST['submit2'])) { $team_name = escape_data($_POST['team_name']); $captain = escape_data($_POST['captain']); $vice_captain = escape_data($_POST['vice_captain']); $description = escape_data($_POST['description']); if($_POST['team_name'] == 'Other') { $team_name = $_POST['textboxother']; } $query = "INSERT INTO cricket_teams (club_id, team_name, captain, vice_captain, description) VALUES ('$id', '$team_name', '$captain', '$vice_captain', '$description')"; $result = @mysql_query ($query); if ($result) { echo '<h3>New Team Created!</h3>'; } } ?>
  21. I want Other to be selected in the drop down box to make things easier for the user. If Egg is selected then sausage is typed in then it makes it confusing. I do not want sausage to be added to the drop down box for future use. I can get either the Other then text box option to work OR the normal selection from the drop down box however I cant get them to work together. <?php if (isset($_POST['submit2'])) { $team_name = escape_data($_POST['team_name']); $captain = escape_data($_POST['captain']); $vice_captain = escape_data($_POST['vice_captain']); $description = escape_data($_POST['description']); if($_POST['team_name'] == 'Other') { $team_name = $_POST['textboxother']; $query = "INSERT INTO cricket_teams (club_id, team_name, captain, vice_captain, description) VALUES ('$id', '$team_name', '$captain', '$vice_captain', '$description')"; $result = @mysql_query ($query); if ($result) { echo '<h3>New Team Created!</h3>'; } } } ?>
  22. No i dont think your quiet along the right lines. All I want is a drop down box with the option "Other" at the bottom. If the option "Other" is selected from the drop down box then whatever is written in the text box below becomes the value of the drop down box. e.g Drop down box: Egg Milk Other (selected) Text box: Sasuage I now want sausage to be put into the database instead of Other etc.
  23. I have a text box under the drop down box. The code is meant to set the variable to the text put into the textbox if the drop down box selection is Other?
  24. Having a bit of trouble, I can only get either Other to work or a selected value from the drop down box to work, here is my code: if (isset($_POST['submit2'])) { if($_POST['team_name'] == 'Other') { $team_name = $_POST['textboxother']; } else { $team_name = escape_data($_POST['team_name']); $captain = escape_data($_POST['captain']); $vice_captain = escape_data($_POST['vice_captain']); $description = escape_data($_POST['description']); $query = "INSERT INTO cricket_teams (club_id, team_name, captain, vice_captain, description) VALUES ('$id', '$team_name', '$captain', '$vice_captain', '$description')"; $result = @mysql_query ($query); if ($result) { echo '<h3>New Team Created!</h3>'; } } } Cheers
×
×
  • 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.