Jump to content

Noumes

Members
  • Posts

    13
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Noumes's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. No worries, rookie here as well.
  2. when you search for a value you use two equal signs ='s if $var1 == 1
  3. I worked with wordpress before knowing what even <?php was. Its a full-featured blog engine which requires minimal work to use within your webpage. having your page end in .php is just telling the server there is specialized language it needs to render, html is fine and completely allowed within php documents. For the most part, you can take your current .html document and save it as .php and when you upload it, it will run the same. Try watching a few of this video series: http://blog.themeforest.net/screencasts/new-wp-video-series-and-free-rockstar-book/ Most of the wordpress implementation comes from template tags (im sure they are explain in the video tutorials somewhere) these are found at: http://codex.wordpress.org/Template_Tags and are VERY detailed.
  4. Try and set it up using variables, so your mail function looks like: //invoke mail function to send email mail($toaddress, $subject, $mailcontent, $fromaddress); so when gathering from post try: $name= trim(ucwords($_POST['name'])); $company= trim(ucwords($_POST['company'])); $telephone= trim($_POST['telephone']); $email= trim($_POST['email']); $toaddress = your@email.com; $fromaddress = "From: webserver@example.com"; $subject = "Feedback from web site"; $mailcontent = "<b>Customer Name</b>: ".$name."\n". <b>Customer Company</b>: ".$company."\n". <b>Customer Telephone</b>: ".$telephone."\n". <b>Customer Email</b>: ".$email."\n".
  5. I think this may help you: http://net.tutsplus.com/tutorials/php/user-membership-with-php/ You can see how different the code looks. and ya the code you posted was from: http://www.phpfreaks.com/forums/index.php?topic=260600.0 I don't see that relating to your application in mind.
  6. I've began writing this down on paper, mostly just arrows and boxes but it does seem to help. Right off the bat I notice something. I was also planning a page to display employee's logged in, and options for them to select such as checkout, and take a break dependent on what their current status was (as you mentioned above also); however, here is where I hit a brick wall. When thinking out to execute this, I had no idea how to tell if the employee was currently clocked in, on break...and so on. I came out with two methods I assumed would be workable: 1. Retrieving the last eventtype in timetable where empid.employees = empid.timetable. ex: - timeid(int,auto) | empid(int) | when(datetime) | eventtype(int) 57 | 2 | 2009-07-14 16:01:20 | 1 58 | 2 | 2009-07-14 17:00:00 | 3 END TABLE so if eventype 1 = checked in, and eventtype 3 = On break, a query which would display an employees current eventtpe would show employee #2 currently on break and for that user displaying an option to end break and resume work. Is that possible? is there a such query to work that operation? the second method is going back and fourth. 2. Adding another row to Employees 'empstatus' which would update corresponding to eventtype changes. so if Bob had empstatus 1, he just logged in and would be shown take a break option or log out option. thanks for the help thus far, its been great.
  7. could you do something like if(isset($_POST['submit'])) { $userid = $_POST['userid']; $password = md5($newpass); mysql_query("UPDATE users SET password='$password', flag='0' WHERE username='$userid'") or die(mysql_error()); print"done"; }
  8. Before reading through, I've uploaded the current version of what I talk about below at: http://mildgreen.com/projects/learnphp/arco.rar this may be easier or not to view the code on your own localhost server for convenience. I have tried to implement what you suggested. The current problem: Won't write values into database. (i've stripped out my html tags like head and the unnecessary div's) <?php if(isset($_POST['submit'])) { $templogin = $_POST['emplogin']; $eventtype = 1; $correctlogin = 'no'; } $mysql = new mysqli('localhost','root','','arco') or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('SELECT empid,emplogin FROM employees'); $stmt->execute(); $stmt->bind_result($empid,$emplogin); ?> <body> <?php while($row = $stmt->fetch()) : ?> <?php if ( $templogin == $emplogin ) { $correctlogin = 'yes'; $tempid = $empid; echo 'correct login found'; } else { $correctlogin == 'no'; } ?> <?php endwhile; ?> <?php if ( $correctlogin == 'yes' ) { $mysql = new mysqli('localhost','root','','arco') or die('There was a problem connecting to the database'); $stmt = $mysql->prepare('INSERT INTO timetable VALUES (NULL,NULL,?,?)'); $stmt->bind_param('ii',$tempid,$eventtype); $stmt->execute(); $stmt->close(); } elseif ( $correctlogin == 'no' ) { echo 'Wrong employee code'; } ?> </div> </body> CREATE TABLE IF NOT EXISTS `employees` ( `empid` int(11) NOT NULL AUTO_INCREMENT, `empname` varchar(30) NOT NULL, `emplogin` int(11) NOT NULL, `groupid` int(11) NOT NULL, PRIMARY KEY (`empid`) ) CREATE TABLE IF NOT EXISTS `timetable` ( `timeid` int(11) NOT NULL AUTO_INCREMENT, `when` datetime NOT NULL, `empid` int(11) NOT NULL, `eventtype` int(11) NOT NULL, PRIMARY KEY (`timeid`) ) there is one employee currently in the database: empid = 1 empname= Nouman emplogin= 1991 groupid=1 After typing in 1991 into the form and hitting submit, I receive the 'echo 'correct login found';' but when I load my database in phpmyadmin, the timetable has nothing inserted into it. If I type the wrong login in, I am returned with the correct response: echo 'Wrong employee code';. So far that means I am able to retrieve the code input, check to see if it matches an employee in the database, but then it won't allow it to write them into the timetable. now again, more than going forward I am worried about my execution and implementation of php and mysql above. If you feel anything is done strangely, or if there is a neater way, or just anything you'd do different, I appreciate it greatly. And as always, thanks for reading.
  9. @xtopolis, I really want to thank you. More than getting this to work first try I want to build a correct understanding and method on how to approach tasks, and for you taking time to show a very detailed method on how you'd properly do it is beyond thanking. My understanding of what your layout is: Employees table: - ID: unique ID for all employees - Names - self explanatory. Employee_groups: - Setting each employee to a group. (could this be another row under employees?) groups - setting what exactly the groups are. (giving meaning to 1 and 2) Timetable is where I get confused. eventtype would be like 1 = signin, 2 = signout, 3= 30min(standard) break? I can't wrap my head around this table for some reason, but I'm going to continue evaluating it. If you have the time It would be greatly appreciated if you could briefly walk me through that table. If it is assigning a value to the events, I can see a use already for possibly listing break times of employees. One thing that I do need however is the employee 'code'. this code would basically correspond to the code they already use to login to the cash register, and it would be the exact same # (four digit) to login. thanks again for taking your time to not just write your reply, but to evaluate my previous posts and logic.
  10. Here's my form: <form method="post" action="login.php" id="test" name="test"> <input type="text" name="code" value="code" /> <input type="submit" value="Check In" id="submit" name="submit" /> </form> and here's my login.php page: <?php if(isset($_POST['submit'])) { $code = $_POST['code']; $mysql = new mysqli('localhost','root','','arco') or die('There was a problem connecting to the database'); if($stmt = $mysql->prepare('INSERT INTO worktimes VALUES (NULL,NULL,?)')) { $stmt->bind_param('s',$code); $stmt->execute(); $stmt->close(); } else { echo 'error: ' . $mysql->error; } } ?> and my databases: name = their name code = login code (ex: 1234) loggedin = 0 or 1, 1 means logged in. This is to display a list of currently logged in users. CREATE TABLE IF NOT EXISTS `employees` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text NOT NULL, `code` int(11) NOT NULL, `loggedin` int(11) NOT NULL, PRIMARY KEY (`id`) ) CREATE TABLE IF NOT EXISTS `worktimes` ( `checkin` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `checkout` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `code` int(11) NOT NULL ) here's my problem, after I did that, I wanted to see how the timestamps worked. I figured automatically and then it hit me. if its automatic, won't checkin and checkout be the same? and I was right. after loggin in here were the results: checkin:2009-07-14 16:37:14 checkout:2009-07-14 16:37:14 code:1996 another issue I noticed, was how do I check to see if the code entered is a valid one before writing to the worktimes table? Meaning how to I check the input against the employees table before inserting the employee code into worktimes. thanks.
  11. Born in Pakistan myself, would be posting besides you if I hadn't moved to the U.S
  12. Thanks for the quick reply and help. I'm posting at night since I've been reading all day and planning the better part of the last hour. I'm going to sleep in a bit but I have this post on email notification and will keep watch. Anyone is welcome to post the more ideas the more concepts to learn (which im dying to do). I'll start first thing tomorrow setting up a 'sandbox' of some sort and laying out what I can recall off memory from the book. (db connect page, admin page, index.php, and the tables)
  13. Hi everyone, Long story short: getting tired of reading php and mysql web dev. From the start I knew I was a hands on learner (as with css and html) it came natural once I began working on items so I decided instead of just flipping threw long pages of words I'd attempt to create what I want through trying (and well apparently asking for help) The application is a simple one: The screen displays the current time and a form. type in your id (ex: 1234) into the form and click 'Check in'. A link on the page links to what is essentially users.php and lists employees who are currently checked into the system showing: Time checked in: & Name: (so 11:00 - John) and next to their name a link to 'Check out'. Now all the check in's and out's would be saved into the mysql database, and through an admin page could be retrieved and sorted by date ( to print user times on payday) Here's my problem.... I haven't a clue what the correct way to set this up would be. What I am thinking: Two databases: 1 called employees' and one called worktimes employees would store the employee user info: rank (to allow or restrict access to the admin page - simple number value 1 or 2), ID (what is entered on main screen to 'check in' to work) Name (their name) Worktimes would store: date check in time check out time employee id (to tell who checked in) really this is all I can think of but to me it already seems unfuctional. for some reason I keep thinking that storing the login/out would work better in the user database instead of in its own and my head is already aching. Any guidance is greatly appreciated, and if you know how you'd set this up PLEASE I'd be grateful to read through it! thanks for taking your own time to even read this.
×
×
  • 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.