
jay93
Members-
Posts
10 -
Joined
-
Last visited
jay93's Achievements

Newbie (1/5)
0
Reputation
-
Hi, i'm currently working on a health website, and i wish to create a page on the website that automatically fetches top articles from a website like http://health.yahoo.net and displays them... i've thought about this for really a long time, but i have no idea on what to do...i ve heard of other people doing similar things like getting their website to display top trending youtube videos, etc... so i really wanted to do this... and another question weighing me down right now is... on another webpage in my health website, i want to create a search box, where users can type their medical queries and it will automatically display results from google and wikipedia (a search box for each)... the issue is i dont want them to be directed to the homepages of google or wikipedia,(which is pretty simple to do) but instead be shown results directly from them... how could i go about this??
-
thanks for your help... i had another question, related to C, linked lists though...could you please help?? assuming you had a double linked list of integers, and three pointer first___ which is a global pointer_, prev and next ...and you had to create a struct node like the following, how will you fill in the dashes?? typedef struct node { _______ prev; // Box I _______ i; // Box II _______ next; // Box III } node; if you look at the function below for a double linked list, does it properly insert items into the tail of the list?? and does it segfaults when inserting into an empty list ie.when first is NULL).?? and what about mem leakage> does it leak when inserting i into an existing list?? thanks void insert(unsigned int i) { node* n = malloc(sizeof(node)); if (n == NULL) { return; } n->prev = NULL; n->i = i; n->next = NULL; if (first == NULL) { first = n; } else if (n->i < first->i) { n->next = first; first->prev = n; first = n; } else { node* ptr = first; while (true) { if (ptr->i == n->i) { return; } else if (ptr->next->i > n->i) { n->next = ptr->next; ptr->next->prev = n; n->prev = ptr; ptr->next = n; return; } ptr = ptr->next; } } }
-
this is what i've got for reset.php.....like i mentioned earlier, is there a way to pass into reset.php the value of $check so that i can use $check[0][id] in it as shown above boldfaced... <?php // configuration require("../includes/config.php"); // if form was submitted if(isset($_POST["submit"])) { if (empty($_POST["password"])) apologize("Please enter password."); if ($_POST["password"] != $_POST["confirmation"]) apologize("Passwords do not match!"); $result = query("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"], $check[0]["id"])); if($result===false) apologize("Could not register. Please retry."); else { $rows = query("SELECT id FROM users WHERE hash = ?", crypt($_POST["password"])); $id = $rows[0]["id"]; // remember that user's now logged in by storing user's ID in session $_SESSION["id"]= $rows[0]["id"]; } // redirect to portfolio redirect("register.php"); } else { // else render form render("register_form.php", ["title" => "Register"]); } ?>
-
found the solution to that problem, in my config.php file declared at the top, i was initializing SESSION...hence the problem... however, the new issue now is my render function works for only templates, so it is rejecting render.php as an invalid template... is there a way i can pass the values in the array $check to my reset.php (which is a controller , not template) , so i could access them in reset.php thus.. (boldened)... and is my logic right?? <?php // configuration require("../includes/config.php"); // if form was submitted if(isset($_POST["submit"])) { if (empty($_POST["password"])) apologize("Please enter password."); if ($_POST["password"] != $_POST["confirmation"]) apologize("Passwords do not match!"); $result = query("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"], $check[0]["id"])); if($result===false) apologize("Could not register. Please retry."); else { $rows = query("SELECT id FROM users WHERE hash = ?", crypt($_POST["password"])); $id = $rows[0]["id"]; // remember that user's now logged in by storing user's ID in session $_SESSION["id"]= $rows[0]["id"]; } // redirect to portfolio redirect("register.php"); } else { // else render form render("register_form.php", ["title" => "Register"]); } ?>
-
found the solution to that problem, in my config.php file declared at the top, i was initializing SESSION...hence the problem... however, the new issue now is my render function works for only templates, so it is rejecting render.php as an invalid template... is there a way i can pass the values in the array $check to my reset.php (which is a controller , not template) , so i could access them in reset.php thus.. (boldened)... and is my logic right?? <?php // configuration require("../includes/config.php"); // if form was submitted if(isset($_POST["submit"])) { if (empty($_POST["password"])) apologize("Please enter password."); if ($_POST["password"] != $_POST["confirmation"]) apologize("Passwords do not match!"); $result = query("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"], $check[0]["id"])); if($result===false) apologize("Could not register. Please retry."); else { $rows = query("SELECT id FROM users WHERE hash = ?", crypt($_POST["password"])); $id = $rows[0]["id"]; // remember that user's now logged in by storing user's ID in session $_SESSION["id"]= $rows[0]["id"]; } // redirect to portfolio redirect("register.php"); } else { // else render form render("register_form.php", ["title" => "Register"]); } ?>
-
@jessica, yeah, i'm using that in my query() function...did you see my latest post, it's about at the same time as urs???
-
Hi, i m trying to write a code for resetting password. I want this code to show in on the log in page (and the user should be able to open it without being logged in),,, however the problem i am facing is, whenever i open my recover form thus, localhost/pass.php , my recover form has a field for email and security question, ) it just shows the login page, which is localhost/login.php... i'm stuck on this now for days, and nothing seems to improve... and just to make helping easier, i'm planning to implement a recover function thus: 1. when the user clicks on forgot password on localhost/login.php without already being logged in, it should take them to a page, pass.php (displaying an email and security question)... 2.and when the users enter both( confirm if they exist in the sql table), then redirect to another form reset.php which shows two fields for "Enter new password" and "Confirm password", and when user enters both, his password is updated in the database... Pass.php has a template pass_form.php and reset.php has a template reset_form.phpp //code for pass.php: <?php // configuration require("../includes/config.php"); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["forgotpassword"])) apologize("Please enter email address."); if (empty($_POST["security"])) apologize("Please enter your security key."); $email = $_POST["forgotpassword"]; if(!(filter_var($email, FILTER_VALIDATE_EMAIL))) apologize("Please enter a valid email such as [email protected]"); //check if email and securitykey exist in users table $check= query("SELECT id, security FROM users WHERE email = ?", $_POST["forgotpassword"]); if ($check === false) apologize("No such user in database"); render("reset.php", ["title" => "Reset Password", "check" => $check]); } else render("login_form.php", ["title" => "Login"]); ?> 3. another problem is when i log in, and then i open localhost/pass.php, it always keeps on rendering the above template called login_form.php( which is linked to the controller login.php...) instead of displaying the pass_form.php template... /// pass_form.php is as follows: <form action="pass.php" method="post"> <fieldset> <div class="control-group"> <input name="forgotpassword" placeholder="Email" type="text"/> </div> <div class="control-group"> <input name="security" placeholder="Security Keyword" type="text"/> </div> <div class="control-group"> <button type="submit" class="btn">Reset</button> </div> </fieldset> </form> RENDER() is a function as follows function render($template, $values = []) { // if template exists, render it if (file_exists("../templates/$template")) { // extract variables into local scope extract($values); // render header require("../templates/header.php"); // render template require("../templates/$template"); // render footer require("../templates/footer.php"); } // else err else { trigger_error("Invalid template: $template", E_USER_ERROR); }
-
thanks for the reply... i did the bracket stuff, but it's still giving me the same problem...r whenever i try to open pass.php thus localhost/pass.php, it doesnt open, but instead the localhost/login.php shows, which is my login page... but when i login and then try to open pass.php, then i face another problem...it displays the login_form.php template linked to the login.php controller (in other words, the login page, even though the user is logged in)... regarding "query" it's a function i'm using to get data from the sql table... this is what i have now for pass.php: <?php // configuration require("../includes/config.php"); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["forgotpassword"])) { apologize("Please enter email address."); } if (empty($_POST["security"])) { apologize("Please enter your security key."); } $email = $_POST["forgotpassword"]; if(!(filter_var($email, FILTER_VALIDATE_EMAIL))) { apologize("Please enter a valid email such as [email protected]"); } //check if email and securitykey exist in users table $check= query("SELECT id, security FROM users WHERE email = $email"); if ($check === false) { apologize("No such user in database"); } render("reset.php", ["title" => "Reset Password", "check" => $check]); } else render("login_form.php", ["title" => "Login"]); ?> and my template for pass.php, pass_form.php is <form action="pass.php" method="post"> <fieldset> <div class="control-group"> <input name="forgotpassword" placeholder="Email" type="text"/> </div> <div class="control-group"> <input name="security" placeholder="Security Keyword" type="text"/> </div> <div class="control-group"> <button type="submit" class="btn">Reset</button> </div> </fieldset> </form> and just to give you a hint of what i'm trying to do, i'm planning to implement a recover function thus: 1. when the user clicks on "forgot password" on localhost/login.php without already being logged in, it should take them to a page, pass.php (displaying an email field and security question field)... 2.and when the users enter both( confirm if they exist in the sql table), then redirect to another form reset.php which shows two fields for "Enter new password" and "Confirm password", and when user enters both, his password is updated in the database... Pass.php has a template pass_form.php and reset.php has a template reset_form.phpp
-
this is my render function...i just realized reset.php is actually a controller instead of a template, could that be causing it??? i actually wanted to pass in the id value that corresponds to email, to reset.php, so that i could use it in reset.php thus... $result = ("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"], $check["id"]); if($result===false) apologize("Could not register. Please retry."); function render($template, $values = []) { // if template exists, render it if (file_exists("../templates/$template")) { // extract variables into local scope extract($values); // render header require("../templates/header.php"); // render template require("../templates/$template"); // render footer require("../templates/footer.php"); } // else err else { trigger_error("Invalid template: $template", E_USER_ERROR); } and by the way, i'm having a similar error with my reset.php file too, whenever i type localhost/reset.php, it just ends up on the login.php page...
-
hi, i m currently working on resetting password feature on my website, and this is what i've got for my pass.php file which receives POST from pass_form.php... anytime i run localhost/pass.php, nothing happens, it always keeps on returning the localhost/login.php (which is my login page)... where could the problem be?? ----apologize and query are functions i'm using to display errors and to interact with teh SQL database respectively... <?php // configuration require("../includes/config.php"); if ($_SERVER["REQUEST_METHOD"] == "POST") { if (empty($_POST["forgotpassword"])) apologize("Please enter email address."); if (empty($_POST["security"])) apologize("Please enter your security key."); $email = $_POST["forgotpassword"]; if(!(filter_var($email, FILTER_VALIDATE_EMAIL))) apologize("Please enter a valid email such as [email protected]"); //check if email and securitykey exist in users table $check= query("SELECT id, security FROM users WHERE email = ?", $_POST["forgotpassword"]); if ($check === false) { apologize("No such user in database"); } else render("reset.php", ["title" => "Reset Password", "check" => $check]); and is this right?? i'm trying to pass the id from this file into another page called reset.php(user inserts new password here), where i access the id this$check[id]..?? } else {render("login.php", ["title" => "Login"]); } ?>