Jump to content

Weiss

Members
  • Content count

    52
  • Joined

  • Last visited

Community Reputation

0 Neutral

About Weiss

  • Rank
    Newbie
  1. Sticky notes

    Thank you very much
  2. Sticky notes

    In case i dont want to direct to another php page but would like to use the same page, what would be the best way to handle this?
  3. Sticky notes

    Hi. Im trying to make an online sticky notes system. each user will be able to subscribe to number of boards. each board will hold memos. so in case me and my friend are subscribed to the same board (we can both subscribe to different boards also regardless) and i put a memo on that board, my friend will see that memo also. So... i crated the sql database, and now when the user logged in, he is automatically see the boards he's subscribed to and the memos on that board. only thing is, i want him to be able to add memo to a board. as for now, the script takes the userid, then run sql query to check his subscribed boards and saves the boards id on an array, after that, on each board, the script loops thru the memos on the database to see which memo is connected to that board id and then display it. so im not sure how can i do the Add note thingy here, i thought about making a little form inside each of the display boards, a simple <teaxtarea> and <submit> and when user submit i run the SELF PHP page and insert a query. ONLY problem is, how can i know which of the forms did the user submitted? if there could be a way the form could hold the board id number inside of it.. is there a way to do that? im posting a pic to try to explain what i mean. **You can see the title of the board in pink, after that all notes float left and the form comes after the notes. in this example to user subscribed to 2 boards. thank you
  4. cannot run query

    Hi. Im scratching my head trying to understand the following issue: i have a built login/signup system. after user will login he will redirect to profile.php where i have a session with all the info i need. i want to run a simple query: $result = $mysqli->query("SELECT boardid FROM connector WHERE userid='$id'"); but for some reason this line kills my script. my $mysqli is working fine in all other php pages... so i try moving this line top to bottom but wherever the page meets this line the script is dead. what am i doing wrong? <?php /* Displays user information and some useful messages */ session_start(); // Check if user is logged in using the session variable if ( $_SESSION['logged_in'] != 1 ) { $_SESSION['message'] = "You must log in before viewing your profile page!"; header("location: error.php"); } else { // Makes it easier to read $first_name = $_SESSION['first_name']; $last_name = $_SESSION['last_name']; $email = $_SESSION['email']; $active = $_SESSION['active']; $id = $_SESSION['id']; } ?> <!DOCTYPE html> <html > <head> <meta charset="UTF-8"> <title>Welcome <?= $first_name.' '.$last_name ?></title> <?php include 'css/css.html'; ?> </head> <body> <div class="form"> <h1>Welcome</h1> <h2><?php echo $first_name.' '.$last_name; ?></h2> <p><?= $email ?></p> <a href="logout.php"><button class="button button-block" name="logout"/>Log Out</button></a> </div> <div> <?php //THIS IS THE LINE THAT KILLS EVERYTHING. IF I PUT IT HERE NOTHING WILL HAPPEND, IF U PUT IT UP THE SCRIPT WILL DIE $result = $mysqli->query("SELECT boardid FROM connector WHERE userid='$id'"); ?> </div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script> <script src="js/index.js"></script> </body> </html>
  5. Little advice about login page

    Hi. I wanna create a signup/login thingy. You can see it at sweiss.co.il/sfn/ . So i have the index.html with 2 forms 1 for login and 1 for signup, each has his own action going to login.php and signup.php , but i want them both leading to something like main.php only problem i dont know how to figure if the user clicked on the submit of the new user or the sumbit of the login as existent user (which obviously make main.php behave differently). Whats the best way to make it happen? Thanx very much in advance
  6. im struggling bad here please help

    Hi. ive been struggling for 2 hours over this and i just cannot understand whats wrong here. im trying to create a signup.php where there is a form in the index. with post method, and the inputs are username, password and confirmed password. in the php file i some functions (like isExist($username) which return true if someone wanna sign up with a username that already exist..) im embedding the code here: <?php //First define some functions.. function isExist ($username){//Return TRUE if name already exist in users table $query = "SELECT * FROM users WHERE username = $username"; $result = mysqli_query($con, $query) or die ('Cannot use SELECT query'); return (mysqli_num_rows($result) != 0);//Since username can be only 1 per name, any number !=0 means 1 actually.. } function passChk($password, $conf_pass){//Return TRUE if pass and confirmed pass match return ($password == $conf_pass); } function newUser ($username, $password){//Add a new user .. duh ;p if (!isExist($username)) { if (passChk($pass, $conf_pass)){ $query = "INSERT INTO 'users' (username, password, id) VALUES ('$username', '$password')"; mysqli_query($con, $query) or die ("Cannot INSERT into Database"); echo 'Username Created successfully'; } else {echo '<script>alert ("Password and confirmed password do not match")</script>'; header("Location: http://www.sweiss.co.il/sfn/index.html"); } } else { echo '<script>alert ("Username already exist!")</script>'; header("Location: http://www.sweiss.co.il/sfn/index.html"); } mysqli_close($con); } //Code start require_once('connectvars.php'); $con = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) or die ('Cannot create connection to Database'); mysqli_set_charset($con, "utf8") or die ('Could not set utf-8');//Will allow us to use hebrew $username = mysqli_real_escape_string($con, trim($_POST['username']));//Defence vs sql injection $password = mysqli_real_escape_string($con, trim($_POST['password'])); $conf_pass = mysqli_real_escape_string($con, trim($_POST['conf_pass'])); newUser ($username, $password); ?> i keep getting the error from the first function isExist.. cannot use SELECT query. plase any help would be much appriciated
  7. Evaluate my knowlage

    Thank you
  8. Evaluate my knowlage

    Hi. I see many web developers pages where they add knowlage percentage of the thechnologies they know (e.g you can see javascript 80%/html 90% and so on). My question is how do they evaluate the percentages ? Are there formal online tests or they just write what they think? Hope i was clear on my questions. Thanx
  9. fetch the data

    hi. i have an array with 8 id numbers (e.g. [4234, 3241, 2313, ....]; i have an sql table with those id numbers among others.. i want to make a query with fetch the data, i can do that with using IN (4234,3241....) but the problem is that i get the data when its oredered by numbers from small to big.. i want it oredered exactly as the array meanning the first row should be with id = 4324, second with 3241 etc... how can i do that? thanx
  10. joinning 3 tables

    Hi. i have 3 tables: orders, customer, custwish. (every table has id prim key, which match the 3 tables, meaning, if a customer has id=20, there's an order with id=20 regarding him and wishid=20 regarding him) i wanna make a query where ill get all info from these tables with the following restrictions: orderid=customerid=custwishid ; livearea(in table customer) =1, delivered(in table orders)= 'n' how can i do that with inner join? thanx!
  11. Well..this cant be right

    Hi. im almost sure im doing something terribly wrong... here goes: i have 2 tables, one for Customer (ID(primary)address,phone...etc..) and one for Order (OrderNumber(primary), order info, date of the order....etc) (both primary auto inc) both have foreign keys which point to the other tables primary key.. Now, when a new order is being made, i insert data to the Order table.... after that i need to insert data to the customer table... So... when i insert data to the order table, i cannot insert data to the foreign key column since i do not know what will be the data inside the primary key column of the customer table. so, now the primary key data in a variable, and go to the customer table and insert the data of the customer and in the foreign key i spit out what was in the variable i saved earlier, after i run the sql command line i can see the id key that have been issued so i save that in a variable. so i have to go back to the order table and insert the data in the foreign key there and NOW i have data in the 2 tables which is connected thru the foreign keys. this MUST be wrong there's no way im doing it right... right?
  12. primary and foregin key

    the idea is this, this first table get filled when customer buy product (primary key is order number which is uniqe, his id, address, name, etc.) the second table is inserted after a few days when the customer enters the site and checkbox his day and time request for when he want the package to arrive. so actually the second table doesnt get inserted at the same time the first one. ive made the first table order number a primary key and wanted to make the second table order number as secondary key so they both point to each other. if i insert null value on the second table key how will it point to the firs table?
  13. primary and foregin key

    i dont think i understand. those are 1 to 1 tables. i can enter data to the main table but how will the data be insreted to the second table if i get an error and i try to insert?
  14. primary and foregin key

    HI! im having a little understanding problem about keys. i have 2 tables. one with ID (primary key) and all kind of other stuff. now i have another table, e.g. adress, where i want to make a uniqe coloum connecting 1 to 1 with the ID of the main table. so what i did is connected the ID (primary key) of the first table to the ID (secondary key) of the second table. so how does that work now? because i cant insert anything to the second table since it gives me an error: #1452 - Cannot add or update a child row: a foreign key constraint fails (`logitech`.`cust_time`, CONSTRAINT `cust_time_ibfk_1` FOREIGN KEY (`order_num`) REFERENCES `customer` (`order_num`)). how can i use the second table exactly? in this situation, the data to the second table should be inserted only a few days after the data to the first table. thank you !
×