lofaifa Posted October 20, 2011 Share Posted October 20, 2011 hello i need someone to take a look on this , General comments on the code process and how should i continue !!! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/249484-need-an-advice-on-how-to-continue/ Share on other sites More sharing options...
Drummin Posted October 20, 2011 Share Posted October 20, 2011 There's no way people are going to "browse" though all those files. Ask a direct question and show the code and any issues. Link to comment https://forums.phpfreaks.com/topic/249484-need-an-advice-on-how-to-continue/#findComment-1280933 Share on other sites More sharing options...
lofaifa Posted October 20, 2011 Author Share Posted October 20, 2011 for example : when i open a session .. should i always write pages for user like this : <?php session_start(); if(isset($_SESSION["user_name"]) && isset($_SESSION["user_password"])){ echo "<html>"; echo "<head>"; echo "<title>Profile Page </title>"; echo "</head>"; echo "<body>"; echo "Welcome ".$_SESSION['user_name'] . " !<br/><br/>" ; echo "<br />"; echo '<a href="add_info.php">Add New informations</a><br/><br/>'; echo '<a href="edit_profile.php">Edit you Profile</a><br/><br/>'; echo '<a href="logout.php">Logout</a>'; } else { echo "you didnt login yet !!.<br/><br/>"; echo '<a href="main.php">Go Back </a>'; } echo "</body>"; echo "</html>"; ?> --------------------------------- <?php require_once("includes/connection.php");?> <?php require_once("includes/functions.php");?> <? session_start(); if(isset($_SESSION["user_name"]) AND isset($_SESSION["user_password"])){ echo '<html>'; echo '<head>'; echo '<title>Editting Page</title>'; echo '</head>'; echo '<body>'; echo '<form action="edit_pro.php" method="post">'; echo '<p>'; echo 'Edit Name : <input type="text" name="new_name" value="" id="new_name" />'; echo '<br/><br/>'; echo 'Edit Password: <input type="password" name="new_password" value="" id="new_password"/>'; echo '</p>'; echo '<input value="Change Now" type="submit" />'; echo '<a href="welcome.php"> Or Go back </a>'; echo '</form>'; echo '</body>'; echo '</html>'; } ?> --------------------------------------- <?php require_once("includes/functions.php");?> <?php session_start(); if(isset($_SESSION["user_name"]) AND isset($_SESSION["user_password"])){ echo '<html>'; echo '<head>'; echo '<title>Set INFO</title>'; echo '</head>'; echo '<body>'; echo 'Here u can post more info :<br/><br/>'; echo '<form action="add_pro.php" method="post">'; echo 'Your Name : <input type="text" name="user_rname" value="" id="user_rname" /><br/><br/>'; echo 'country : <input type="text" name="user_country" value="" id="user_country" /><br/><br/>'; echo 'Name of Your blog : <input type="text" name="user_blog" value="" id="user_blog" /><br/><br/>'; echo '<input value="Add info" type="submit" /><br/><br/> '; echo '<a href="welcome.php">To go Back </a><br/><br/>'; echo '</form>'; echo '</body>'; echo '</html>'; } ?> Link to comment https://forums.phpfreaks.com/topic/249484-need-an-advice-on-how-to-continue/#findComment-1280937 Share on other sites More sharing options...
floridaflatlander Posted October 20, 2011 Share Posted October 20, 2011 I'm kind of new to sessions myself but why session['password'] ? You just need the users password at the time of login You show that they have a profile and they are editing something, do they have an id#, is user_name unique? I'm writing from memory, this is basically how I would do it. if (id_profile == $_SESSION['id_profile']) { allow edit } else { kick them to the curb } you can get id_profile with a $_GET for the above or have a profile.php page and have if ($_SESSION['id_profile']) { $query = "SELECT this, that FROM table WHERE id_profile = $_SESSION['id_profile']"; Display all the their stuff here } else { redirect or something } Link to comment https://forums.phpfreaks.com/topic/249484-need-an-advice-on-how-to-continue/#findComment-1280942 Share on other sites More sharing options...
lofaifa Posted October 20, 2011 Author Share Posted October 20, 2011 okay thanks man , ill try to change to apply this ! but i have another question .. soo this is the general way how websites with users registred works ?? and is there any better way to write an HTML page under a php tag without a lot of echo s !? Link to comment https://forums.phpfreaks.com/topic/249484-need-an-advice-on-how-to-continue/#findComment-1280963 Share on other sites More sharing options...
floridaflatlander Posted October 20, 2011 Share Posted October 20, 2011 but i have another question .. soo this is the general way how websites with users registred works ?? and is there any better way to write an HTML page under a php tag without a lot of echo s !? Yes and <?php if (isset($_SESSION["user_name"]) { ?> <html> <head> <title>Set INFO</title> </head> <body> Here u can post more info :<br/><br/> <form action="add_pro.php" method="post"> Your Name : <input type="text" name="user_rname" value="" id="user_rname" /><br/><br/> country : <input type="text" name="user_country" value="" id="user_country" /><br/><br/> 'Name of Your blog : <input type="text" name="user_blog" value="" id="user_blog" /><br/><br/> <input value="Add info" type="submit" /><br/><br/> <a href="welcome.php">To go Back </a><br/><br/> </form> </body> </html> <?php } else { redirect or what ever } ?> Link to comment https://forums.phpfreaks.com/topic/249484-need-an-advice-on-how-to-continue/#findComment-1280965 Share on other sites More sharing options...
lofaifa Posted October 20, 2011 Author Share Posted October 20, 2011 thank you .. Link to comment https://forums.phpfreaks.com/topic/249484-need-an-advice-on-how-to-continue/#findComment-1280969 Share on other sites More sharing options...
floridaflatlander Posted October 20, 2011 Share Posted October 20, 2011 or <?php if (isset($_SESSION["user_name"]) { echo '<html> <head> <title>Set INFO</title> </head> <body> Here u can post more info :<br/><br/> <form action="add_pro.php" method="post"> Your Name : <input type="text" name="user_rname" value="" id="user_rname" /><br/><br/> country : <input type="text" name="user_country" value="" id="user_country" /><br/><br/> Name of Your blog : <input type="text" name="user_blog" value="" id="user_blog" /><br/><br/> <input value="Add info" type="submit" /><br/><br/> <a href="welcome.php">To go Back </a><br/><br/> </form> </body> </html>'; } else { redirect or what ever } ?> Link to comment https://forums.phpfreaks.com/topic/249484-need-an-advice-on-how-to-continue/#findComment-1280971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.