SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mass data inserting using for loops and while loops

    Hey all i am having trouble to create a script that will mass insert into database using for loop and while loop

    the only problem is that i have a button at the end and just does nothing heres my code

    PHP Code:
        $t=1;
        ?>
            <form method="post" action="">
            <table border="1" align="center">
        <tr>
                    <th>Username:</th>
                    <th>Password:</th>
                    <th>Email:</th>
                    <th>Rank:</th>
        </tr>
        <?
        $l
    =40;
        while(
    $t<=$l)
        {
            
    $uservar="user".$t;
            
    $rankvar="rank".$t;
            
    $passvar="pass".$t;
            
    $emailvar="email".$t;
            echo 
    "    
            <tr>
                <th><input type=text size=20 name=
    $uservar value=$uservar></th>
                <th><input type=password name=
    $passvar value=1234></th>
                <th><input type=text name=
    $emailvar value=$emailvar></th>
                <th><select name=
    $rankvar>";
            
    $i=0;
            
    $j=1;
            for(
    $i=$j$i>=1$i--)
            {
                
    getRankByNum();
            }
            
    $t++;
            echo
            
    "</select></th>
            </tr>"
    ;
        }
    ?>
    <tr>
        <th align="center" colspan="4"><input type="submit" name="ad" value="Mass Add Members"></th>
    </tr>
    </table></form>
    <?php
    if($_POST['ad'])
    {
        
    $user=$_POST['$uservar'];
        
    $pass=$_POST['$passvar'];
        
    $email=$_POST['emailvar'];
        
    $rankvar=$_POST['rankvar'];
        if(
    $user || $pass || $email || $rankvar)
        {
                
    $i=0;
                
    $j=40;
                for(
    $i=$j$i>=0$i--)
                {
                    include(
    "dbconnect.php");
                    
    $pQuery="insert into members values ('','$user','$pass','$rankvar','$email','$aim','','1','','$recruiter','','$today','','','','','','','','','','','','','','','','','','','','','0')";
                            echo 
    "Query".$t."&nbsp; is".$pQuery;
                            
    //$LQuery="INSERT INTO logs Values('','$rank','$recruiter','sucessfully recruited $username on','$today','Recruitment')";
                            //$rQuery="update members set recruits=recruits+1 where username='".$_SESSION['user']."'";
                            
    $result=mysqli_query($con,$pQuery);
                            
    //$result=mysqli_query($con,$LQuery);
                            //$result=mysqli_query($con,$rQuery);
                            
    if(!$result)
                            {
                                echo 
    "<font color=".$fontcolor.">Error:".mysqli_connect_errno();
                                echo 
    "<br/><font color=".$fontcolor.">Error2:".mysqli_error($con);
                            }
                            else
                            {
                                echo 
    "<font color=".$fontcolor."><br/><br/>Member Add to Clan<br/>
                                        The Recruits Login information is as follows:<br/>
                                        <br/>
                                        Username: 
    $user <br/>
                                        Password: 
    $pass <br/>
                                        <br/>
                                        <br/>
                                        Please Make Sure the Recruit Logins and Changes his password
                                        </font>"
    ;
                                        
    //echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=index.php?cmd=console\">";
                                        
    mail("$email""Welcome to $ClanName!""$username
                                        Welcome to 
    $ClanName!  You are now, the newest member of our great clan!  
                                        ____________________________________________________________
                                        Here is your information:
                                        User Name:            
    $username
                                        Password:            
    $password
                                                
                                        Ensure you don't lose this information.  If you have a problem with loggin in, please
                                        feel free to contact an officer and they can assist you.
                                        ____________________________________________________________"
    );
                            }
                }
            
    //rest of button code
        
    }
    }
    So How can i go about fixing this Problem all the button does is say the button is all undefined i have tried to echo back the queryy but doesnt do anything else

    How can i fix this?

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Are you sending ones password in an email...? That is very very VERY BAD. You are also displaying it on the page that is just as bad.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well its only for a person who has certain access any idereas how i can get the button to work and how can i make it more secure this way?

  4. #4
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why is the action attribute of the form set to " ", where are you supposed to be sending this data ?
    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.

  5. #5
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    to the button which has A query which is going back to that page.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •