-
Posts
462 -
Joined
-
Last visited
-
Days Won
1
Content Type
Profiles
Forums
Events
Posts posted by Mudsaf
-
-
-
video upload
in PHP
W3schools.com ~ Tutorial
http://www.w3schools.com/php/php_file_upload.asp
Tizag ~ Tutorial
http://www.tizag.com/phpT/fileupload.php
If you want video players etc you need to merge that with SQL.
-
index.php
<?phpsession_start();if (isset($_SESSION['username'])) {//User has logged inecho "Logged in as: " . $_SESSION['username'];} else {echo "<h3>Login to have access on page.</h3><form method='post' action='login.php'>Username: <input type='text' name='user'>Password: <input type='password' name='pass'><input type='submit' value='Login'></form>";}?>
login.php
<?phpsession_start();$user = "John"; //Example username$pass = "125Eas%"; //Should do this with SQL but easier to understand with phpif (!isset($_SESSION['username'])) {if (isset($_POST['user']) && $_POST['user'] == $user && isset($_POST['pass']) && $_POST['pass'] == $pass) {$_SESSION['username'] = $_POST['user'];echo "<p>Login success. You are logged in as: " . $_SESSION['username'] . "</p>Return to mainpage, click <a href='index.php'>here</a>!";} else {echo "<p>Wrong username or password.</p>";}} else {echo "Already logged in as: " . $_SESSION['username'];}?>
-
Xampp has folder "htdocs" which is related to www or public_html folder and this folder would have all your website files inside it.
You can check the info at apache (httpd.conf) and search this line below.
DocumentRoot /var/www/html
You might have different location on "DocumentRoot" but its your htdocs folder.
-
Without PHP & SQL you can't really make safe login for your page. Also form GET method isn't secure way to do it.
Here is some tutorial how to make login with SQL: http://www.phpeasystep.com/phptu/6.html
-
<html><head><style>.co1 {background-color:#F1F1F1;padding:2 4 2 4;border:groove;border-width:thin;}.co0 {background-color:#DBDBDB;padding:2 4 2 4;border:groove;border-width:thin;}.toptd {font-weight:bold;border:groove;border-width:thin;padding:2 4 2 4;}a { text-decoration:none; }</style><script src="lightbox/js/jquery-1.10.2.min.js"></script><script src="lightbox/js/lightbox-2.6.min.js"></script><link href="lightbox/css/lightbox.css" rel="stylesheet" /></head><body><form action='/stash/index.php' method='GET'><input type='text' name='search'><input type='submit' value='Search'></form> <a href='additem.php' target='_BLANK'>Add item</a><table><tr><td class='toptd'>Page</td><td class='toptd'>Amount</td><td class='toptd'>Item</td><td class='toptd'>Update Date</td><td class='toptd'>Image</td></tr><tr><td class='co1'>100</td><td class='co1'>1</td><td class='co1'>Umbar's Blade Short Sword</td><td class='co1'>2014-01-29 00:41:50</td></tr><tr><td class='co0'>100</td><td class='co0'>1</td><td class='co0'>Magma Spike Gladius</td><td class='co0'>2014-01-28 23:07:06</td><td style='text-align:center;' class='co0'><a href='img/magma-spike-gladius.jpg' data-lightbox='Magma Spike Gladius'><img width='16' height='16' src='img/magma-spike-gladius.jpg'></a></td></tr><tr><td class='co1'>77</td><td class='co1'>1</td><td class='co1'>Skeleton Soul</td><td class='co1'>2014-01-28 22:43:50</td><td style='text-align:center;' class='co1'><a href='img/skeleton-soul.jpg' data-lightbox='Skeleton Soul'><img width='16' height='16' src='img/skeleton-soul.jpg'></a></td></tr><tr><td class='co0'>77</td><td class='co0'>2</td><td class='co0'>Hungry Dead Soul</td><td class='co0'>2014-01-28 22:36:53</td><td style='text-align:center;' class='co0'><a href='img/hungry-dead-soul.jpg' data-lightbox='Hungry Dead Soul'><img width='16' height='16' src='img/hungry-dead-soul.jpg'></a></td></tr><tr><td class='co1'>100</td><td class='co1'>1</td><td class='co1'>Shadow Slice Hatchet Hands</td><td class='co1'>2014-01-28 20:13:18</td><td style='text-align:center;' class='co1'><a href='img/shadow-slice.jpg' data-lightbox='Shadow Slice Hatchet Hands'><img width='16' height='16' src='img/shadow-slice.jpg'></a></td></tr><tr><td class='co0'>71</td><td class='co0'>10</td><td class='co0'>Ancient Decipherer</td><td class='co0'>2014-01-28 19:42:09</td><td style='text-align:center;' class='co0'><a href='img/ancient-decipherer.jpg' data-lightbox='Ancient Decipherer'><img width='16' height='16' src='img/ancient-decipherer.jpg'></a></td></tr><tr><td class='co1'>71</td><td class='co1'>8</td><td class='co1'>Ancient Scroll</td><td class='co1'>2014-01-28 19:41:27</td><td style='text-align:center;' class='co1'><a href='img/ancient-scroll.jpg' data-lightbox='Ancient Scroll'><img width='16' height='16' src='img/ancient-scroll.jpg'></a></td></tr><tr><td class='co0'>70</td><td class='co0'>11</td><td class='co0'>Dragonstone</td><td class='co0'>2014-01-28 19:22:59</td><td style='text-align:center;' class='co0'><a href='img/dragonstone.jpg' data-lightbox='Dragonstone'><img width='16' height='16' src='img/dragonstone.jpg'></a></td></tr></table></body></html>
<td class='co1'>100</td><td class='co1'>1</td><td class='co1'>Umbar's Blade Short Sword</td><td class='co1'>2014-01-29 00:41:50</td><!-- Should have td here --></tr><tr>
-
I'm using MySQLi
PHP receive
if ($res_ginfo = $con->query("SELECT <column1>, <column2> FROM <table> WHERE <column1> = '" . $row['<data1>'] . "'")) {$rows = mysqli_num_rows($res_ginfo);if ($rows == 1) {$row_ginfo = $res_ginfo->fetch_assoc();echo "<td style='text-align:center;' class='co" . $count . "'><a href='" . $row_ginfo['<data2>'] . "' data-lightbox='" . $row['item'] . "'><img width='16' height='16' src='" . $row_ginfo['<data2>'] . "'></a></td>";} else {echo "<td style='text-align:center;' class='co$count'><form enctype='multipart/form-data' style='margin:0;' action='upimg.php' method='POST'><input type='hidden' value='" . $row['<data1>'] . "' name='item'><input type='file' name='image'><input type='submit' value='Upload'></form></td>";}}
Error occurs on at if ($rows == 1) { echo td lines.
It effects that much it just doesn't create TD tags and the table 5th column is empty at that line.
However the bug is fixed if i add ' to SQL text instead of ', but the it will display /' on the td tag.
-
But shouldn't prepared query prevent from SQL injections already?
if ($stmt = $con->prepare("INSERT INTO <table> (<column1>, <column2>, <column3>) VALUES (?,?,?)")) {
And the SQL-data just removes 1 table td codes.
<td></td>
-
Hello, i'm wondering how my single quote @ SQL-table can break my code.
Example: Who's that? <-- Breaks code
Example2: Whos tat? <-- Doesn't break code
Tried below
htmlspecialchars (with ent_quotes and without)
htmlentities(-ll-)
-
Hi i want to have my personal webserve on my system in order to publicise my website on internet. Pls how can i do it? Thank you all. Am new here.
I recommend you to check your upload speed at speedtest.net & make sure you have at least 5MB upload bandwith. If your website will get alot of traffic/downloads it would lag you & all others who's visiting your server.
Good hosting websites for free & paid.
Free: http://byethost.com/
-
Wondering if Primary key's are made for SQL clients, so they know how to work with rows. Example if i delete row at SQL it says.
DELETE FROM items WHERE id = '1'DELETE FROM items WHERE id = '5'DELETE FROM items WHERE id = '6'DELETE FROM items WHERE id = '8'
-
HTML & Php
in PHP
Yea i usually use .PHP also, unless i have to work with styling and i don't have apache server nearby. I love the PHP include so i don't have to write same code dozen times to every page.
- 1
-
Well i'm updating it for company & they'r using font-size instead of zooming. The website page width = 800px (which has sidebar included, i have like 500px to work around) so content will go to next line if increased text-size. I assume i have to do it the ugly way because it was their company's request. >_>
-
Hello, i've got website to edit and wondering do you guys support the "IE" View->Text Size->Largest option? I could make the website look alot better without supporting it.
-
Alright i think i have to edit margin from left, was just wondering the align change at div. Was it too width because of the margin left? Anyway changed it to margin: 0 auto;
-
Hello, i'm wondering how to keep the div positions sticky even when adding content to them.
<html><head><meta charset="utf-8"/><style>div {border:groove;border-width:thin;}#left-navi {width:200px;height:400px;display:inline-block;text-align:center;padding:2px;}#right-navi {width:150px;display:inline-block;height:400px;padding:2px;text-align:center;}#mid-navi {display:inline-block;width:800px;height:400px;padding:2px;}#content {margin-left:150px;width:1178px;padding:15px;}h2 {margin:5px 2px 10px 2px;}</style></head><body><div id="content"><h2>MyWebsite</h2><div id="left-navi"></div><div id="mid-navi"></div><div id="right-navi"></div></div></body></html>
-
Thanks for all replies, i will try those when i'll get back to home.
-
Figured out now, made single $row variable and pasted the 4th one up there & ignored it on while loop, nvm didin't work >_>
-
Hello, how i can get certain value from while loop to top of the list? I don't wanna touch SQL-query.
Example my while loop result
12345
What i want
41235
-
Lol i actually made working script without knowing it >_>
-
Hello, i'm wondering how to call php function with some variables sent on the way.
Example
function runScript($MyVar, $MyData) {echo $MyVar; //Should return 1echo $MyData; //Should return Data}$MyVar = 1;$MyData = "Data";runScript($MyVar, $MyData);
-
Note: The values "inline-table", "table", "table-caption", "table-cell", "table-column", "table-column-group", "table-row", "table-row-group", and "inherit" are not supported in IE7 and earlier. IE8 requires a !DOCTYPE. IE9 supports the values.
http://www.w3schools.com/cssref/pr_class_display.asp
See examples what it does at here
http://www.brunildo.org/test/inline-block2.html
-
Yea some kind of policy page sounds good, but i assume that at my page there is nothing to hide since all data would be away in password protected folders or at database. My page currently has Shoutbox which kind a "logs" anyways even tho you should because the shouts will be always in database either hidden or visible.
By the logging at the moment i meant mostly SQL-errors and that kind of logging.
-
I'm wondering can you really have too much logging on your website.
Currently i'm logging data with
- SQL database logging
- Mail function to own error log email <made this because SQL might be down>
Wondering should i make ip-related .txt file logging also if mail & sql servers are off?
error
in PHP
Posted · Edited by Mudsaf
I think you should do it like this