Board index   FAQ   Search  
Register  Login
Board index php forum :: Database mySQL & php coding

Please help i need it badly :(

Codes here !

Moderators: macek, egami, gesf

Please help i need it badly :(

Postby vinsux » Tue Jul 10, 2012 7:09 am

I'm newbie in Php.. I still have to learn many things.. but pls. help me in my big problem.. :(

The logic of my code is Suppose that the student is already logged in his account..
there's a page where it restricts a user to enter the page and he needs to register on that page..
without entering any details or it's just a button saying "Ask To Join"..
There's no syntax error.. but it directly goes to verified.php but the user needs to be verified..
to explain it simply, it's just like the YAHOO GROUPS.. where you need to join to access the group..


Please.. people with a good heart.. pls. help me... it will be very much appreciated.. Thank you very much..

Code: Select all
<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("login") or die(mysql_error());

$errors="";
$message="";

$username = $_COOKIE['ID_my_site'];

   if (isset($_POST['submit'])) {
            

         $check = "SELECT $username FROM students";
         $result = mysql_query($check) or die(mysql_error());
         while($row = mysql_fetch_array($result))
              {
             $id = $row['id'];
              $username = $row['username'];
             $namelast = $row['namelast'];
              $namefirst = $row['namefirst'];
             $namemi = $row['namemi'];
             }
            $insert = "INSERT INTO pendings (id, username, namelast, namefirst, namemi)
            VALUES ($id, $username, $namelast, $namefirst, $namemi)";
            $add_member = mysql_query($insert) or die(mysql_error());   
            
            if (mysql_affected_rows()==1){
               $message .= "<h1>Registered</h1>
               <p>Thank you, Please wait for the approval of the faculty teacher who handles the subject.</p>";
            }
         }
      else
      {
       header("location:verified.php");
      }
   
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

      <br />
       
      <input type="text" name="username" maxlength="60"value="$namelast"/>
      <input type="hidden" name="namelast" maxlength="20" value="$namefirst" />
           <input type="hidden" name="namefirst" maxlength="20" value="$namemi" />
      <input type="hidden" name="namemi" maxlength="20" value="$username" />
               <input type="hidden" name="namemi" maxlength="20" value="$id" />

      <center><br /><br /><input type="submit" name="submit" value="Ask to Join"  style="width: 100px; height: 30px"/></center>
     
</form>
 
vinsux
New php-forum User
New php-forum User
 
Posts: 9
Joined: Wed Jun 20, 2012 6:26 am

Re: Please help i need it badly :(

Postby johnj » Tue Jul 10, 2012 8:37 pm

follow the simple logic, make sure you are doing what you want.

for example:

if (user is verified)
{
go to verified page
}
else
{
ask the user to register.
}
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: Please help i need it badly :(

Postby vinsux » Thu Jul 12, 2012 9:02 am

Pls. help.....


is there a method that you can set two links in an <a href>..?


If the logged in is student..

the HOME Button will redirect to student page

If the logged in is faculty...

the HOME Button will redirect to student page..

Thank
vinsux
New php-forum User
New php-forum User
 
Posts: 9
Joined: Wed Jun 20, 2012 6:26 am


Return to mySQL & php coding

Who is online

Users browsing this forum: Bing [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron