Jump to content

tbucknall

Members
  • Posts

    3
  • Joined

  • Last visited

tbucknall's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi there! I am wondering if anyone can assist my on creating a simple php script for creating, modifying and deleting users with PHP ONLY. No MySQL. I am quite new to PHP. I need it to be so that only an administrtaor can make those changes and visitors only have a log in page and home page. So far i only have the register and login working. I want to know how i can set up so an adminstrator can modify the users. thanks. this is the register script: <?php echo "password1 ".$_POST['password']; echo "<br>"; echo "password2 ".$_POST['password2']; echo "<br><br>"; if (isset ($_POST['submit'])) { $problem = FALSE; if (empty ($_POST['username'])) { $problem = TRUE; print "Please enter a username!"; } if (empty ($_POST['password'])) { print "Please go back and enter a password" ; exit; } if (empty ($_POST['password2'])) { print "Please go back enter your password in each box."; exit; } if (($_POST['password'])!==($_POST['password2'])) { print "Your password entries did not match! Please go back and correct them."; exit; } $fp = fopen ( 'users.txt', 'rb' ); while ($line = fgetcsv($fp,100,",")) { echo $line[0]." ".$line[1]; echo "<br>"; if ( ($line[0] == $_POST['username']) ) { echo "<b>Sorry! That username is already being used. Please go back and select another name.</b>"; fclose ( $fp ); exit; } } $fp=fopen('users.txt', 'ab' ); //$data =($_POST['username']).crypt($_POST['password']); $data =($_POST['username']).",".($_POST['password'])."\r\n"; fwrite ( $fp, $data ); fclose ( $fp ); print "You are now registered!"; } exit; ?> and this is the login: <?php //debug echo $_POST['username']; echo "<br>"; echo $_POST['password']; echo "<br>"; // end debug if (isset ($_POST['submit'])) { $loggedin = FALSE; $fp = fopen ( 'users.txt', 'rb' ); while ($line = fgetcsv($fp,100,",")) { echo $line[0]." ".$line[1]; echo "<br>"; //debug if ( ($line[0] == $_POST['username']) AND ($line[1] == ($_POST['password']) ) ) { $loggedin = TRUE; echo "line 24 <br>"; //debug //break; } } if ($loggedin) { print '<br>Username and Password are correct.'; exit; } else { print '<br>The username and password did not match!'; } } ?> <form action="login.php" method="post"> Username: <input type="text" name="username"> <br /><br /> Password: <input type="password" name="password"> <br /><br /> <input type="submit" name="submit" value="Login"> </form>
  2. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <form action="#" method="GET"> <input type="hidden" name="firstName" value="Tadd"/> <input type="hidden" name="lastName" value="Bucknall"/> <input type="hidden" name="stuID" value="100834575"/> Rows: <select name="Rows"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> <br /> Columns: <select name="Columns"> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> <br /> <input type="text" placeholder="Please enter a color" name="color"/> <br /> <input type="submit" name="submit" value="Try it"/> </form>
  3. Hi all, very very new to php, Just wondering it i could get anyones help with these steps. Thanks in advanced. Create a page called lab1.php In lab1.php, create a Form with the following inputs: Dropdown with options from 1 to 10, labeled “Rows:” Another Dropdown with options from 1 to 10, labeled “Columns:” Submit button [*] The form should submit values to “table.php” using the GET method [*] Create a page called table.php [*] In table.php, read the values submitted from lab1.php by referencing the appropriate indexes in the $_GET array. [*] In table.php, construct a table that has: The amount of rows entered in part 2a The amount of columns entered in part 2b Your first name in every ODD cell(1,3,5,7...) . Your name can be a string literal i. Ex: <td>JOHN</td> 7. Add the following styles to the top of the table.php page: <style> td{ border: 1px solid black; } </style>
×
×
  • 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.