Jump to content

Ell20

Members
  • Posts

    337
  • Joined

  • Last visited

    Never

Everything posted by Ell20

  1. Thanks for the help but it dosent seem to have solved the problem, still not menu or test message appearing.
  2. Hey, Im attempting to make a special menu for the Admin of the site which only they can see. Im getting no errors but it dosent seem to be working. //Function function getUserInfo($user_id,$fields){ $sql="select $fields from `users` where user_id='$user_id' "; $query=mysql_query($sql); $rows=mysql_num_rows($query); if($rows==0){return;} $rs=mysql_fetch_assoc($query); return $rs; } //Code <?php require_once ('../mysql_connect.php'); include_once ('includes/functions.php'); $user_id = $_SESSION['user_id']; $userinfo=getUserInfo($user_id, '*'); $member_type = $userinfo['member_type']; $sql = "SELECT * FROM users WHERE member_type='$member_type'"; $result = @mysql_query($sql); if($result['member_type'] == "Admin"){ ?> Message Will Appear If Admin <a href="admin.php">Admin Test</a><br /> <? } ?> Any help would be appreciated Cheers
  3. Thank you very much, seems to be working perfectly!!
  4. This makes up my full query: $query = "INSERT INTO users (username, club_id, member_type, first_name, last_name, email, password, registration_date) VALUES ('$u', $_POST['clubdrop'], 'Member', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )"; $result = @mysql_query ($query); However by adding in the $_POST['clubdrop'] section has caused an error: Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `T_NUM_STRING' in c:\program files\easyphp1-8\www\html\registermember.php on line 63 Appreciate your help
  5. Thanks cmgmyr, your code works, however its the getting the club_id value to go into the database that I am having difficulties with? Cheers
  6. Hey thanks for the reply, but im still very new to php so im sorry but I dont really understand how to do that. I know that I have already started a session however in another page called header.html which is included on the page. I have added some more code so you maybe able to see where I am going wrong. Cheers $query = "INSERT INTO users (username, member_type, first_name, last_name, email, password, registration_date) VALUES ('$u', 'Member', '$fn', '$ln', '$e', PASSWORD('$p'), NOW() )"; $result = @mysql_query ($query); if ($result) { echo '<h3>Thank you for registering!</h3>'; include ('includes/footer.html'); exit(); mysql_close(); } else { echo '<p><font color="red" size="+1">You could not be registered due to a system error. We apologize for any inconvenience.</font></p>'; } } else { echo '<p><font color="red" size="+1">That username is already taken.</font></p>'; } mysql_close(); } else { echo '<p><font color="red" size="+1">Please try again.</font></p>'; } } ?> <h1>Join Your Club</h1> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <fieldset> <table border="0" align="center"> <tr> <td>First Name:</td> <td><input type="text" name="first_name" size="30" maxlength="15" value="<?php if (isset($_POST['first_name'])) echo $_POST['first_name']; ?>" /></td> </tr> <tr> <td>Last Name:</td> <td><input type="text" name="last_name" size="30" maxlength="30" value="<?php if (isset($_POST['last_name'])) echo $_POST['last_name']; ?>" /></td> </tr> <tr> <td>Email Address:</td> <td><input type="text" name="email" size="30" maxlength="40" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></td> </tr> <tr> <td>Select your club:</td> <td> <?php require_once ('../mysql_connect.php'); $sql="SELECT * FROM club"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $club_id=$row["club_id"]; $clubName=$row["clubn"]; $options.="<OPTION VALUE=\"$club_id\">".$clubName.'</option>'; } ?> <select name="clubdrop"> <option value=0>Select Your Club <?=$options?> </select>
  7. Just read what I have written and its a bit misleading so ill try again. I want to store the $club_id value from the option selected into a table in the database. Here is my dynamic drop down box which works: <? require_once ('../mysql_connect.php'); $sql="SELECT * FROM club"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $club_id=$row["club_id"]; $clubName=$row["clubn"]; $options.="<OPTION VALUE=\"$club_id\">".$clubName.'</option>'; } ?> <select name="clubdrop"> <option value=0>Select Your Club <?=$options?> </select> Cheers
  8. Hey, Im looking for some help in storing a value from a dynamic drop down box into a table. Here is my dynamic drop down box which works: <? require_once ('../mysql_connect.php'); $sql="SELECT * FROM club"; $result=mysql_query($sql); $options=""; while ($row=mysql_fetch_array($result)) { $club_id=$row["clubn"]; $clubName=$row["clubn"]; $options.="<OPTION VALUE=\"$club_id\">".$clubName.'</option>'; } ?> <select name="clubdrop"> <option value=0>Select Your Club <?=$options?> </select> I am already storing some values from other parts of the form but I am unsure on how to store the $club_id of the club selected into the table at the same time? Cheers
  9. Im having some trouble with putting data from a form into 2 seperate tables. //Adds data into club table: club_id (auto increment), type of website and club name = working fine $query1 = "INSERT INTO club (webtype, clubn) VALUES ('$membertype', '$clubn')"; $result = @mysql_query ($query1); //I also need to put club_id into the users table so getting the data from the clubs table $sql = "SELECT * FROM club WHERE clubn='$clubn'"; $result = mysql_query($sql); $clubdata = mysql_fetch_array($result); $clubid=$clubdata['club_id']; //This query here dosent insert anything into the table, no errors, just no data $query2 = "INSERT INTO users (username, club_id, member_type, first_name, last_name, email, password) VALUES ('$username', '$clubid' 'Admin', '$fname', '$surname', '$email', '$pass1')"; $result = @mysql_query ($query2); } Appreciate any help Cheers
  10. Im having some trouble with putting data from a form into 2 seperate tables. //Adds data into club table: club_id (auto increment), type of website and club name = working fine $query1 = "INSERT INTO club (webtype, clubn) VALUES ('$membertype', '$clubn')"; $result = @mysql_query ($query1); //I also need to put club_id into the users table so getting the data from the clubs table $sql = "SELECT * FROM club WHERE clubn='$clubn'"; $result = mysql_query($sql); $clubdata = mysql_fetch_array($result); $clubid=$clubdata['club_id']; //This query here dosent insert anything into the table, no errors, just no data $query2 = "INSERT INTO users (username, club_id, member_type, first_name, last_name, email, password) VALUES ('$username', '$clubid' 'Admin', '$fname', '$surname', '$email', '$pass1')"; $result = @mysql_query ($query2); } Appreciate any help 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.