Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
[QUOTE=Tehgameze;42949201]Please can someone let me know their feedback and recommendations for improvement for this website, [url]www.joketwist.com[/url].
Thank you[/QUOTE]
[code]
<!-- Begin #header -->
</header>
</div>
<div class="ddsmoothmenu" id="topMenu">
</div>
<br>
<br>
<!-- End #header -->
[/code]
This is a bit funky.
Maybe it's just my browser that doesn't write the end tag, or something.
Also the amount of whitespace is huge.
when making a user account system for a website
where do I start? I don't care if it's secure or not; even just having a document which says this is fine
[code]
User1:
{
username: admin
password: AAAAAB
permissions: 777
}
[/code]
since I didn't know how to make an actual user database that isn't a minecraft/source game server, the best I've done is this:
[URL]http://cronosdage.x10.mx/login.php[/URL]
literally combines the username and password given and adds ".htm" to the end
so user "hl3admin" pass "gaben" gives you [URL]http://cronosdage.x10.mx/hl3admingaben.htm[/URL] which is just a childish rickroll. but you can just enter anything and it will bring you to that.htm
(index won't work because my homepage is PHP)
[b]question 2[/b]
is there any way I can make a text-entry box focus on page load?
Hi, usually people use mysql for a database, and I'm guessing you don't know how to do that.
Now you can either learn mysql (it's really not that hard), or perhaps you could handle it in the php.
Seeing as how (normally) the client can't see the php code, you could just put this in the code:
[code]
if($_POST['username'] == "bananaphone" && $_POST['password'] == "hello")
{
// Insert code for correct users here
}
else
{
// yea that's no good, probably want something like:
header("location: index.php");
}
[/code]
Then again, this does not allow people to create an account and the code will get very messy if you add more than 1 person, really.
In sql, the thing you want to do is probably create a table like this (A table with a username, password, and an email):
[code]
CREATE TABLE IF NOT EXISTS `users` (
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
PRIMARY KEY (`username`,`password`),
UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
[/code]
The code would then be
[code]
// Creates a new database connection
$mysql_server = 127.0.0.1; // Database server ip address, probably not this
$database = "database_name"; // You set this when you create it
$mysql_user = "root"; // Username to get in the database
$mysql_pass = ""; // Password for the database
$identifier = new PDO('mysql:host='. $mysql_server. ';dbname='. $database, $mysql_user, $mysql_pass);
//This is the sql code needed to get a username from the database (aka it checks if the username/password combination exists in the database)
$query = "SELECT `username` FROM `users` WHERE `username`=:v1 AND `password`=:v2";
$stmt = $identifier->prepare($query);
// Safely binds the variables (to counter mysql-injection)
$stmt->bindParam(':v1', $_POST['username']);
// change the salt to something else. When inserting new users, use the same function to add the password
$stmt->bindParam(':v2', hash("aSalt123", $_POST['password'] ));
$stmt->execute();
$query_result = $stmt->fetch();
// gets the username, if its empty, that means nothing was found.
$username = $query_result['username'];
if($username != "")
{
// Yay a correct user
}
else
{
// Darnit a wrong combination
}
[/code]
I get that this is a lot though, and you'll need to set up a database (I can help you with that if you like)
After that you don't need to know sql to manually add users to the database if you wish.
Edit: Almost forgot about the textbox focusing. You could either use the "autofocus" attribute ( <input type="text" name="name" autofocus />, also super unsupported by IE 9 and lower ), or you could use javascript, as shown [URL="http://stackoverflow.com/questions/3383429/setting-focus-on-an-html-input-box-on-page-load"]here[/URL].
thanks a lot; I haven't used mysql in years
put your information in a document to use in the future
[QUOTE=mdeceiver79;42945710]Multisite real time reporting for epos, for now will just be sales with some forms for cash declarations. Once released more modules will be added for loyalty, stocks etc.
The users will have an overview of events that day then be able to quickly filter and drill down on events and transactions for full details.
edit: also an alert feed flagging suspect events, similar to facebook notifications.[/QUOTE]
minimizing all the js as it goes out would make it significantly more difficult for somebody to steal it and reuse it.
also doing lots of things with no comments and having unhelpful or misleading function names.
[QUOTE=gokiyono;42949352][code]
<!-- Begin #header -->
</header>
</div>
<div class="ddsmoothmenu" id="topMenu">
</div>
<br>
<br>
<!-- End #header -->
[/code]
This is a bit funky.
Maybe it's just my browser that doesn't write the end tag, or something.
Also the amount of whitespace is huge.[/QUOTE]
What browser are you using?
Also It's a similar basis, I would appreciate any feedback on [url]www.giftshuffle.co.uk[/url] as well, am in the process of bug fixing and still developing at the moment so am aware of some faults.
[QUOTE=Tehgameze;42956265]What browser are you using?
Also It's a similar basis, I would appreciate any feedback on [url]www.giftshuffle.co.uk[/url] as well, am in the process of bug fixing and still developing at the moment so am aware of some faults.[/QUOTE]
Waterfox.
When I press Suitable for/change the price range, nothing really happens. And I have to press load more to see it.
And maybe it would be a good idea to instead of having each shuffle in the shuffle viewer, have x of y shuffle there.
[QUOTE=gokiyono;42956387]Waterfox.
When I press Suitable for/change the price range, nothing really happens. And I have to press load more to see it.
And maybe it would be a good idea to instead of having each shuffle in the shuffle viewer, have x of y shuffle there.[/QUOTE]
I know, am trying to work that out, there is actually an animation that pushes in and pulls out new shuffles. Will have a look into Waterfox.
Thank you
[QUOTE=Tehgameze;42956419]I know, am trying to work that out, there is actually an animation that pushes in and pulls out new shuffles. Will have a look into Waterfox.
Thank you[/QUOTE]
Waterfox is just firefox in 64 bit.
What would be the easiest way to delete elements from a list using a link on the page? This is for an assignment so i think i have to use a link... I can't use jQuery either. Is there some easy ajax trick?
[code]
<div id="thelist"><ul id="control">
<li class="button" onclick="sortTable(0, 'str', '1');" ondblclick="sortTable(0, 'str', '-1');">Item</li>
<li class="button" onclick="sortTable(1, 'str', '1');" ondblclick="sortTable(1, 'str', '-1');">Code</li>
<li class="button" onclick="sortTable(2, 'num', '1');" ondblclick="sortTable(2, 'num', '-1');">Price</li>
<li class="button" onclick="sortTable(3, 'num', '1');" ondblclick="sortTable(3, 'num', '-1');">Quantity</li>
<li class="button" onclick="sortTable(4, 'num', '1');" ondblclick="sortTable(4, 'num', '-1');">Amount</li><li/></ul><?php
function makeTable()
{
$doc = new DOMDocument();
$doc->load('db.xml');
$entries = $doc->getElementsByTagName("entry");
$str = "";
$curId = 0;
foreach($entries as $entry)
{
$item = $entry->getElementsByTagName("item")->item(0)->nodeValue;
$code = $entry->getElementsByTagName("code")->item(0)->nodeValue;
$price = $entry->getElementsByTagName("price")->item(0)->nodeValue;
$quantity = $entry->getElementsByTagName("quantity")->item(0)->nodeValue;
$amount = $entry->getElementsByTagName("amount")->item(0)->nodeValue;
$str = $str . "<ul id='" . $curId . "'>";
$str = $str . "<li class = 'item'>" . $item . "</li>";
$str = $str . "<li>" . $code . "</li>";
$str = $str . "<li class = 'number'>" . $price . "</li>";
$str = $str . "<li class = 'number'>" . $quantity . "</li>";
$str = $str . "<li class = 'number'>" . $amount . "</li>";
$str = $str . "<li>Remove</li></ul>"; // this needs to remove the row
$curId++;
}
echo ($str . "</div></section>");
}[/code]
[QUOTE=twoski;42960272]What would be the easiest way to delete elements from a list using a link on the page? This is for an assignment so i think i have to use a link... I can't use jQuery either. Is there some easy ajax trick?[/QUOTE]
if you cant use jquery, just use javascript????
[QUOTE=RusselG;42962689]if you cant use jquery, just use javascript????[/QUOTE]
jQuery IS JavaScript.
[QUOTE=twoski;42960272]What would be the easiest way to delete elements from a list using a link on the page? This is for an assignment so i think i have to use a link... I can't use jQuery either. Is there some easy ajax trick?
[code]
<div id="thelist"><ul id="control">
<li class="button" onclick="sortTable(0, 'str', '1');" ondblclick="sortTable(0, 'str', '-1');">Item</li>
<li class="button" onclick="sortTable(1, 'str', '1');" ondblclick="sortTable(1, 'str', '-1');">Code</li>
<li class="button" onclick="sortTable(2, 'num', '1');" ondblclick="sortTable(2, 'num', '-1');">Price</li>
<li class="button" onclick="sortTable(3, 'num', '1');" ondblclick="sortTable(3, 'num', '-1');">Quantity</li>
<li class="button" onclick="sortTable(4, 'num', '1');" ondblclick="sortTable(4, 'num', '-1');">Amount</li><li/></ul><?php
function makeTable()
{
$doc = new DOMDocument();
$doc->load('db.xml');
$entries = $doc->getElementsByTagName("entry");
$str = "";
$curId = 0;
foreach($entries as $entry)
{
$item = $entry->getElementsByTagName("item")->item(0)->nodeValue;
$code = $entry->getElementsByTagName("code")->item(0)->nodeValue;
$price = $entry->getElementsByTagName("price")->item(0)->nodeValue;
$quantity = $entry->getElementsByTagName("quantity")->item(0)->nodeValue;
$amount = $entry->getElementsByTagName("amount")->item(0)->nodeValue;
$str = $str . "<ul id='" . $curId . "'>";
$str = $str . "<li class = 'item'>" . $item . "</li>";
$str = $str . "<li>" . $code . "</li>";
$str = $str . "<li class = 'number'>" . $price . "</li>";
$str = $str . "<li class = 'number'>" . $quantity . "</li>";
$str = $str . "<li class = 'number'>" . $amount . "</li>";
$str = $str . "<li>Remove</li></ul>"; // this needs to remove the row
$curId++;
}
echo ($str . "</div></section>");
}[/code][/QUOTE]
On delete button click [URL=https://developer.mozilla.org/en-US/docs/Web/API/Node.removeChild]ul.parent.removeChild(ul)[/URL] then manually create a [URL=https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest]XMLHttpRequest[/URL].
[QUOTE=Moofy;42965515]jQuery IS JavaScript.[/QUOTE]
yes jquery is javascript, and they said they cant use jquery, so I said dont use jquery, but plain javascript. you dont seem to get what i said.
[QUOTE=Moofy;42965515]jQuery IS JavaScript.[/QUOTE]
I'm assuming he was not told to use any library, such as jQuery, to help him out. I don't know what's so hard to understand.
[QUOTE=jung3o;42967265]I'm assuming he was not told to use any library, such as jQuery, to help him out. I don't know what's so hard to understand.[/QUOTE]
I miss understood the essential problem, so I was eyeballing the jQuery / JavaScript comparison.
[editline]Edited:[/editline]
Anyone using SFTP with Sublime Text and Lithium? I've been trying to configure this for a while now and it's not working, contacted the support but they refuse to provide information and blame it on my editor, anyone think they could help?
[QUOTE=Moofy;42968305]Anyone using SFTP with Sublime Text and Lithium? I've been trying to configure this for a while now and it's not working, contacted the support but they refuse to provide information and blame it on my editor, anyone think they could help?[/QUOTE]
well to start out, do you have the private key file that the sftp looks for?
[QUOTE=jung3o;42970663]well to start out, do you have the private key file that the sftp looks for?[/QUOTE]
When using a private key with Sublime SFTP i need to have pageant running for some reason, even though i've set the path to the key in the config
Ok so i have to use a GET request on a local separate php script then somehow retrieve the results as formatted XML.
[code]
$opts = array('http'=>array('method'=>"GET",'header'=>"Accept-language: en\r\n"));
$context = stream_context_create($opts);
$result = file_get_contents("http://localhost/1/search.php?item=" . $_POST["item"], false, $context);
[/code]
However, $result is an empty string...
Here is search.php
[code]
<?php
function searchForAllInstances()
{
$item = $_GET["item"];
$xml = new DOMDocument;
$xml->load('db.xml');
$matches = getMatches($xml, $item);
$xsl = new DOMDocument;
$xsl->load('db.xsl');
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
return $proc->transformToXML($xml);
}
function getMatches($doc, $item)
{
$xpath = new DOMXPath($doc);
$highest = '';
$result = $xpath->evaluate('//order/item');
$array = array();
foreach ($result as $node)
{
if ($node->textContent == $item)
{
array_push($array, $item);
}
}
return $array;
}
searchForAllInstances();
?>
[/code]
[QUOTE=twoski;42976507]Ok so i have to use a GET request on a local separate php script then somehow retrieve the results as formatted XML.
[code]
$opts = array('http'=>array('method'=>"GET",'header'=>"Accept-language: en\r\n"));
$context = stream_context_create($opts);
$result = file_get_contents("http://localhost/1/search.php?item=" . $_POST["item"], false, $context);
[/code]
However, $result is an empty string...
Here is search.php
[code]
<?php
function searchForAllInstances()
{
$item = $_GET["item"];
$xml = new DOMDocument;
$xml->load('db.xml');
$matches = getMatches($xml, $item);
$xsl = new DOMDocument;
$xsl->load('db.xsl');
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
return $proc->transformToXML($xml);
}
function getMatches($doc, $item)
{
$xpath = new DOMXPath($doc);
$highest = '';
$result = $xpath->evaluate('//order/item');
$array = array();
foreach ($result as $node)
{
if ($node->textContent == $item)
{
array_push($array, $item);
}
}
return $array;
}
searchForAllInstances();
?>
[/code][/QUOTE]
If you can edit the other PHP file then just use JSON instead.
[CODE]
json_encode($data);
json_decode(file_get_contents($url), true);
[/CODE]
I don't think we're allowed to use json. Part of the assignment is that we have to use a GET request and search.php has to be a separate file.
[QUOTE=twoski;42978429]I don't think we're allowed to use json. Part of the assignment is that we have to use a GET request and search.php has to be a separate file.[/QUOTE]
XML and JSON are just data formats. The reasons you've given don't rule out JSON.
[url]http://localhost/1/search.php?item=15[/url] could output either JSON or XML for item 15.
If your teacher has had you learn to use XML then use XML for this, but you really should know that there is a better way to do it.
So after some serious time of configuring SFTP and arguing with LithiumHosting I finally got it working, they were saying I shouldn't use SSH, and one said I should. How weird, so I told them which one of them was speaking the truth and suddenly they realize they've put wrong information in their knowledge database.
Such a fail, but it works so yay me!
[QUOTE=eternalflamez;42949758]Hi, usually people use mysql for a database, and I'm guessing you don't know how to do that.
Now you can either learn mysql (it's really not that hard), or perhaps you could handle it in the php.
Seeing as how (normally) the client can't see the php code, you could just put this in the code:
stuffd you'll need to set up a database (I can help you with that if you like)
After that you don't need to know sql to manually add users to the database if you wish.
Edit: Almost forgot about the textbox focusing. You could either use the "autofocus" attribute ( <input type="text" name="name" autofocus />, also super unsupported by IE 9 and lower ), or you could use javascript, as shown [URL="http://stackoverflow.com/questions/3383429/setting-focus-on-an-html-input-box-on-page-load"]here[/URL].[/QUOTE]
Plaintext passwords?
Ah, knew I forgot something. Edited.
I'm doing an assignment for school but I have no idea on how to solve this, basically we got this table as shown below:
[IMG]http://i40.tinypic.com/nb43mb.png[/IMG]
The form at the top should figure out between the two categories what the customer needs in the table.
Now logically I would say i should set a variable for each choice(?) - And then say if this plus this link to this. Or is that wrong, have no idea how to tackle it really. :suicide:
[QUOTE=Moofy;42985293]I'm doing an assignment for school but I have no idea on how to solve this, basically we got this table as shown below:
[IMG]http://i40.tinypic.com/nb43mb.png[/IMG]
The form at the top should figure out between the two categories what the customer needs in the table.
Now logically I would say i should set a variable for each choice(?) - And then say if this plus this link to this. Or is that wrong, have no idea how to tackle it really. :suicide:[/QUOTE]
If you need to process the selection server-side I would do something like that.
[code]
<form name="weirdForm" action="someEndpoint" method="POST">
<label>Hvilken something Moofy</label><br/>
<input type="radio" name="selection1" value="option1" checked/>Mit har er turist<br/>
<input type="radio" name="selection1" value="option2"/>What language is this?<br/>
<input type="radio" name="selection1" value="option3"/>Danish?<br/>
<hr>
<label>Er dit blah bananas</label><br/>
<input type="radio" name="selection2" value="option1" checked/>Ja<br/>
<input type="radio" name="selection2" value="option2"/>Neg<br/>
<hr/>
<input type="submit" name="submit"/>
</form>[/code]
And then check the contents of the selection1/2 POST variables to determine what to output.
In PHP for instance:
[code]
$_POST['selection1']; // Will be either option1, option2 or option3
$_POST['selection2']; // Will be either option1 or option2
[/code]
If you want to do it client-side, you can use the same code without the submit button, and then listen for the "change" event using JavaScript.
Is there a guide for a one page website where a content box slides in relating to the link thats clicked?
I want a big image as the background, nav bar at the bottom and then the content is in the middle..
I have the template down and will post pics when I'm at home.
-snip- found it
Never mind seem to of got it working.. (for now).
EDIT:
I do have a new question..
On my website, I want to create a like 'ticker' that presents random facts about me after x amount of seconds / minutes.. what would be the best language to learn and program this? would it be easy?
Sorry, you need to Log In to post a reply to this thread.