Jump to content

sp00ks

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Everything posted by sp00ks

  1. thank you so much! you answered all my questions. Though I have two more now.. heh... IIS? that would be the server, like apache? and with MS SQL 2008 express I can do everything as the retail version, but with storage restriction of 1gm ram and 4 gb data. Can i create views, procedures and triggers still? thanks!
  2. Hey everyone, I'm going to be downloading a version of MS SQL(thinking 2005?) I have MySQL(wamp, so apache as well) on my computer right now, and was wondering if its okay to have them both on one computer, do i have to install another server for MS SQL or will apache work? I haven't really used MS SQL since school(i've used access and oracle as well), but many jobs are looking for this skill. so I was wondering how it compares to mySQL? and if there is a really great book or website which best describes its functions in detail. I'm also wondering what version of MS SQL 2005 or 2008, and what edition, express, etc. (free would be the best, as I'm just updating my skills) I should get? (I know MS SQL is new, but employers are still looking for 2005 experience, would not knowing 2005 and knowing 2008 make a huge difference?) I will be using MS SQL with ASP.Net, but wondering how well it works with PHP, can I call the database the same way as I did with MYSQL? sorry for all the confusing questions, any extra information would be excellent! thanks!
  3. Thanks that worked wonderfully. I guess if the input is going to be text(or anything) i have to call it as such. thanks for the quick answer! EDIT: not sure how to mark my title as [solved]...
  4. I thought i figured out how to allow the user to insert a number, and then get php to call a function to figure out the radius of that number. I am getting the right number back, but also an error message. This tells me my structure of the code is incorrect. If you know a better way to implement this that would be excellent. thanks! Error: Notice: Use of undefined constant radius - assumed 'radius' in C:\wamp\www\****.php on line 13 code: <?php //define a function if(!isset($_POST['submit'])){ ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> Enter the radius of the circle<input type="text" name="radius" size="5"/> <input type="submit" name="submit" value="Go"/> </form> <?php }else { $rad = $_POST[radius]; getCircumference($rad); } function getCircumference ($radius){ echo"Circumference of a circle with radius $radius is ".sprintf("%4.2f", (2 * $radius * pi()))."<br />"; } ?>
  5. thanks works great! should I take notifications off? or does it matter?
  6. I think my main problem is displaying the data that I retrieve from the query. I really don't have much of an idea on how to display it, if I want a certain one row,column, or if I wanted to display each and every row. I know people use the mysql_fetch_array, and other techniques, but I don't understand it(even after reading about it) i guess i'll keep trying!
  7. heh, oh yeah Notice: Undefined index: action in C:\wamp\www\php_sandbox\supertest\form_feedback.php on line 19 works fine if the user is not admin.
  8. actually your code is pretty simple to understand. The only error I received was on line 19. which is if($_GET['action'] == 'delete' && $_GET['user']){ which comes from if($_GET['action'] == 'delete' && $_GET['user']){ if(!$user['IsAdmin']){ die("You are not authorized"); } $q = sprintf("DELETE FROM users WHERE Username = '%s'",mysql_real_escape_string($_GET['user']));; $result = mysql_query($q) or die("Database query failed"); // This will redirect them to the same page (without the URL variables) // just in case they try to hit refresh header('Location: '.$_SERVER['PHP_SELF']); exit; }
  9. Ill definitely give that a read, just in a time crunch to finish this section. I have it so if you are Admin you will be redirected into delete.php, which I will use some code to delete the row from mysql. Is that possible? if($user['IsAdmin'] == 'y'){ echo '<td align="left">'. '<a href="delete.php">Delete</a>' .'</td>'; }
  10. thanks so much, I'm familiar with other languages but php seems to give me a hard time. Anyways, for the button, I basically just want it to delete the row, no need to redirect me to another page. so I assume its POST. The delete will be right next to each row that my program creates. (I have five rows, so five delete buttons beside each one, when the corresponding row is delete, it just gets removed from mysql) In the ($user['IsAdmin']) i can add just sql code? such as DELETE * FROM users WHERE (this is the hard part) *the delete button corresponds to the row* ??? so confusing, heh.
  11. [solved] the last part, still trying to figure out how to display all the users and passwords. not just the one you logged in with. and figuring out how to add a delete button to remove User, assuming you are admin
  12. Thank you guys so much! you are really quick at replying. I just wanted to know how would I display all the records? (each user name and password beside it all) I tried to remove limit 1 but it was unsuccessful ??? I'm also trying to make it, if you are a admin, you can view the IsAdmin row(which displays, y or n) <?php if($row = mysql_fetch_array($result)){ //Only need to select 1 row if($row['IsAdmin'] == 'y'){ echo '<table align="center" border = "1" cellspacing="1" cellpadding="1" width="20%"><tr><td align="center"><b>Name</b></td><td align="center"><b>Password</b></td><td align="center"><b>Delete</b></td></tr>'; echo '<tr><td align="left">' . $row['Username'] . '</td><td align="left">'. $row['Pwd'] . '</td><td align="left">'. $row['IsAdmin'] .'</td></tr></table>'; } else if($row['IsAdmin'] == 'n'){ echo '<table align="center" border = "1" cellspacing="1" cellpadding="1" width="20%"><tr><td align="center"><b>Name</b></td><td align="center"><b>Password</b></td></tr>'; echo '<tr><td align="left">' . $row['Username'] . '</td><td align="left">'. $row['Pwd'] . '</td></tr></table>'; }else{ echo '<p class="error">Invalid Username/Password.</p>'; } } ?> I'm pretty sure i have my curly brackets messed up, but i can't seem to position them right
  13. Hey, Im new here and I have a small problem that I just can't wrap my head around. Basically, I want it so that a user can log on with his username and password from SQL database. when he logs on he can see all the other usernames and passwords, and an option to delete them(if he has administrative rights) basically I'm still stuck on the first part, I can't get all the fields to appear, and my "Username or Password not found" always displays 4 times! <?php //1. Create a database connection $connection = mysql_connect("localhost", "root", "****"); if(!$connection){ die("Database connection failed: " . mysql_error()); } //2. Select a database to use $db_select = mysql_select_db("testing", $connection); if(!$db_select){ die("Database failed: " . mysql_error()); } ?> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> <style type="text/css" title="text/css" media="all"> .error { font-weight: bold; color: #C00 } </style> <title>Form Feedback</title> </head> <body> <?php if ( empty($_POST['name']) || empty($_POST['password'])) { echo '<p class="error">Please go back and fill out the form again.</p>'; } ?> <?php $name = $_POST['name']; $pass = $_POST['password']; $q = ( "SELECT Username,Pwd,Admin FROM users"); $result = mysql_query($q); if(!$q){ die("Database query failed: " . mysql_error()); } while ($row = mysql_fetch_array($result)) { //4. Use returned data if( $name == $row['Username'] && $pass == $row['Pwd']){ echo '<table align="center" border = "1" cellspacing="1" cellpadding="1" width="20%"><tr><td align="center"><b>Name</b></td><td align="center"><b>Password</b></td></tr>'; echo '<tr><td align="left">' . $row['Username'] . '</td><td align="left">'. $row['Pwd'] . '</td></tr> '; } else{ echo"hey"; } } ?> </table> </body> </html> <?php //5. Close connection, Woudl've made it an include file, if I was not sending through email' if(isset($connection)){ mysql_close($connection); } ?> And my login screen <html> <title>Login</title> <body> <h1 align='center'>Please Log In</h1> <form method = "post" action = "handle_login.php"> <table align='center' border = '1'> <tr> <th> Username </th> <td> <input type = "text" name = "name" /> </td> </tr> <tr> <th> Password </th> <td> <input type = "password" name = "password"/> </td> </tr> <tr> <td colspan ='2' align = 'center'> <input type = "submit" value = "Log In"/> </td> </tr> </table> </form> </body> </html> thank you!
×
×
  • 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.