Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
rotaryfun
Jun 30, 2008

you can be my wingman anytime
Yes and that fixed it. Thank you so much! Something so simple.

Adbot
ADBOT LOVES YOU

IT Guy
Jan 12, 2010

You people drink like you don't want to live!

Munkeymon posted:

There are plenty of ways to do it, but I doubt they're all that easy:

http://www.informatik.uni-frankfurt.de/~markus/antiword/

Go do Office interop in .Net to pull out the text yourself (or make office print to a PDF printer)

Take your chances with this http://www.phpclasses.org/browse/package/3553.html.

Thanks.

I've tried a few of the classes on PHP Classes which have proven to be pretty clunky.

Maybe it would be easier to write a script to tree through the network folder and list all of the PDFs, which brings me to another question. Does anyone know of a way to automate PDF creation through folders either with a script or program or some type of cron job?

e. Adobe Acrobat Pro will let me batch create PDFs but it won't tree through a folder structure.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

rotaryfun posted:

Yes and that fixed it. Thank you so much! Something so simple.

Those are invariably the things that take the longest to figure out and cause the most frustration :)

Thirteenth Step
Mar 3, 2004

I'm trying to attach some basic Javascript validation using this code:

code:
<script type='text/javascript'>
function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}
</script>



<img src="bcs_logo.jpg">

</p>
<p>
	<form action='' method='post'>
		Username: <input type='text' name='username'><br>
		Password: <input type='password' name='password'><br>
</p>
		<input type='submit' onclick="isAlphanumeric(document.getElementById('lettersnumbers'), 'Letters and numbers Only Please')" value='Log In'><input type='reset' value='Reset'>
</form>
to the basic PHP login page I made earlier in the page.

I can't seem to get the textareas to validate (via javascript) in conjunction with the PHP, does it make sense that it doesn't work? I can't think of a reason why it wouldn't.

Does Javascript have any problems with PHP at any time?

Thirteenth Step fucked around with this message at 01:32 on Apr 1, 2010

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:

Thirteenth Step posted:

I'm trying to attach some basic Javascript validation using this code:

code:
		<input type='submit' onclick="isAlphanumeric(document.getElementById('lettersnumbers'), 'Letters and numbers Only Please')" value='Log In'><input type='reset' value='Reset'>
</form>

You need <form onsubmit="return isAlphanumeric(...);"

(returning false stops the submit from proceeding).

Edit: change onclick to onsubmit and add it to the form tag. I always forget that.

Edit2:
\/\/ It's been a long day. Also I think this is the first time I had to edit my "Edit:".

Tad Naff fucked around with this message at 03:56 on Apr 1, 2010

epswing
Nov 4, 2003

Soiled Meat
You don't want onclick in your form tag, you want onsubmit.

code:
<form action="blah.php" method="post" onsubmit="return validationMethod()">
Edit: Oh sorry FeloniousDrunk, I didn't see your edit.

DoctorScurvy
Nov 11, 2005
More of a passing curiosity, really

Lumpy posted:

Your convoluted PHP is actually protecting you somewhat. If you really want to gently caress things up, try putting in usernames with fun stuff like this: aaa';DELETE FROM users WHERE 1 or aaa';UPDATE users SET password = 'z' WHERE 1;
Just for info: by default, mysql_query does NOT support using semicolons to separate multiple statements, so this sort of injection isn't an issue. The only way this can be done is by manually enabling options that allow it.

http://dev.mysql.com/doc/refman/5.1/en/c-api-multiple-queries.html

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

DoctorScurvy posted:

Just for info: by default, mysql_query does NOT support using semicolons to separate multiple statements, so this sort of injection isn't an issue. The only way this can be done is by manually enabling options that allow it.

http://dev.mysql.com/doc/refman/5.1/en/c-api-multiple-queries.html

Thanks for the info. It's been a loooong while since I have done "manual" queries and couldn't remember if that stuff worked or not ( did it ever? )

Thirteenth Step
Mar 3, 2004

FeloniousDrunk posted:

You need <form onsubmit="return isAlphanumeric(...);"

(returning false stops the submit from proceeding).

Edit: change onclick to onsubmit and add it to the form tag. I always forget that.

Edit2:
\/\/ It's been a long day. Also I think this is the first time I had to edit my "Edit:".

like:

code:
<p>
                <form action='' method='post' onsubmit="return isAlphanumeric(document.getElementById('lettersnumbers'), 'Letters and numbers Only Please')">
		Username: <input type='text' name='username'><br>
		Password: <input type='password' name='password'><br>
</p>
		<input type='submit' value='Log In'><input type='reset' value='Reset'>
                </form>
? (thanks for the replies)

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:

Thirteenth Step posted:

like:

code:
<p>
                <form action='' method='post' onsubmit="return isAlphanumeric(document.getElementById('lettersnumbers'), 'Letters and numbers Only Please')">
		Username: <input type='text' name='username'><br>
		Password: <input type='password' name='password'><br>
</p>
		<input type='submit' value='Log In'><input type='reset' value='Reset'>
                </form>
? (thanks for the replies)

Looks reasonable, except for that crazy <form> and <p> intermingling. <form> and <p> are both blocks by default so probably you don't need the <p>.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

FeloniousDrunk posted:

Looks reasonable, except for that crazy <form> and <p> intermingling. <form> and <p> are both blocks by default so probably you don't need the <p>.

And if you do, the P should be either inside the form or wrapping it:

code:

<!-- BAD, BAD, BAD. -->
<p>
 <form>
  <input><br />
  <input><br>
</p>
  <input>
 </form>

<!-- BETTER -->
<p>
 <form>
  <input>
  <input>
  <input>
 </form>
</p>

<!-- BEST -->
<form>
 <input>
 <input>
 <input>
</form>
Also, don't have / use form RESET buttons, unless there's a very, very, very specific need for them. They are only clicked on by accident, and they piss people off.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Lumpy posted:

And if you do, the P should be either inside the form or wrapping it:
code:
<!-- BEST -->
<form>
 <input>
 <input>
 <input>
</form>
Can I ask, how should I handle something like a table inside a form? Like if I want to do something like

code:
<form>
    <p>
        <input><br>
        <input><br>
        <input>
    </p>
    <table>
        <tr><td>Description</td><td><input></td></tr>
        <tr><td>Description</td><td><input></td></tr>
        <tr><td>Description</td><td><input></td></tr>
        <tr><td>Do something:</td><td><submit></td></tr>
    </table>
    <input>
    <submit>
    <submit>
</form>
How would you go about doing this in a fashion that's in line with your "best" way of doing it?

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


I'd just use a list if it was just label/input pairs.

code:
  <form method="post" action="login.php" id="userdataForm">
    <fieldset>
      <ul>
        <li>
          <label for="username">Username</label>
          <input type="text" name="username" id="username" class="required"/>
        </li>
        <li>
          <label for="password">Password</label>
          <input type="password" name="password" id="password" value="" class="required password"/>
        </li>
        <li>
          <input type="submit" name="action" id="action" value="Log In" class="btn"/>
        </li>
      </ul>
    </fieldset>
  </form>

duz fucked around with this message at 23:02 on Apr 1, 2010

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

duz posted:

I'd just use a list if it was just label/input pairs.

Doesn't quite do what he intended, lining up labels and stuff.

My answer: just use a drat table. Maybe it's not the most semantic, but it works, and you can get back to worrying about more important parts of your site. I googled around the other day looking at various ways of doing forms, and it seemed like everybody just had all sort of solutions like using dd/dt tags. Then you have to use a bunch of CSS, all just to get it to look like a table!

DarkLotus
Sep 30, 2001

Lithium Hosting
Personal, Reseller & VPS Hosting
30-day no risk Free Trial &
90-days Money Back Guarantee!
I am pretty sure it is acceptable to have a structure like this:
code:
<form>
<table>
</table>
</form>
http://www.html4.com/mime/markup/php/standards_en/html_forms_en/html_forms_6.php

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Yeah, I was just asking out of curiosity about how Lumpy felt it should be done. I got the impression that he thinks it "best" not to have block elements inside a <form>, so I wasn't sure what he thought was the best way of doing it. I've used <form><table></table></form> on some of my pages and they valudate as 401 transitional, which is all I really want.

Hammerite fucked around with this message at 23:45 on Apr 1, 2010

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Hammerite posted:

Yeah, I was just asking out of curiosity about how Lumpy felt it should be done. I got the impression that he thinks it "best" not to have block elements inside a <form>, so I wasn't sure what he thought was the best way of doing it. I've used <form><table></table></form> on some of my pages and they valudate as 401 transitional, which is all I really care about.

Blocks inside blocks are fine, if they actually *do* something. I was more pointing out that having a block who's only child element is another block is pointless.

I tend to structure my forms along these line, but it's not set in stone obviously because not every UI has the same requirements:

code:
<form>
 <fieldset>
  <label>text</label> <input>
  <label>text</label> <input>
  <label>text</label> <input>
 </fieldset>
 <fieldset>
  <label>text</label> <input>
  <label>text</label> <input>
  <label>text</label> <input>
 </fieldset>

</form>

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Lumpy posted:

Blocks inside blocks are fine, if they actually *do* something. I was more pointing out that having a block who's only child element is another block is pointless.

Oh right. That makes more sense! I see your point now.

Thirteenth Step
Mar 3, 2004

I found out what was stopping it, i forgot to enter the 'id=textboxname' into the code, i presumed it would operate from this "name=textboxname"

thanks for that help guys, and i'm not usually this messy with code, it'll get tidied up soon!

Sorry for talking about javascript in a PHP thread too... :ohdear:

I'll be back on the PHP soon... :ohdear:

duz
Jul 11, 2005

Come on Ilhan, lets go bag us a shitpost


fletcher posted:

Doesn't quite do what he intended, lining up labels and stuff.

That's presentational, which is what CSS is for:

code:
#userdataForm ul {
padding:0;
margin:0;
list-style-type:none;
}
#userdataForm li {
clear:both;
line-height:2em;
}
#userdataForm label {
text-align:right;
width:125px;
display:block;
float:left;
white-space:nowrap;
}
Edit: I just noticed, this is the PHP thread. Why arn't we discussing this in the web design thread?

AbsentMindedWelder
Mar 26, 2003

It must be the fumes.
This is some code I found on the Internet and am trying to get it work. I've played with it a number of ways and can't make it work right. The problem I'm having is that the variable 'fvalue' doesn't seem to be making it where it needs to be.

I'm sure the problem is a simple one, but it has me stumped. I tried googling PHP variables with no success. My server is running Debian and has PHP5 installed on it.

parallel.php:
code:
<?php

  switch (@$_GET['do'])                               
  {

    case "update":
	{
		echo ("<center><br>Data sent to parallel port (0x$fvalue)</br></center>");

		exec ("/usr/sbin/lptout 0x$fvalue");
		include("parallel.inc");
	}
	break;             

    default:                                             
        include("parallel.inc");
  }
?>
parallel.inc:
code:
<html>
<head><title>Parallel Port Controller</title></head>
<body topmargin="0" leftmargin="0" marginheight="0"
      marginwidth="0">
         <center><form action="parallel.php?do=update" method="POST"> 
         <table border="0">
          <tr><td align=right><b>Value (HEX)</b></td>
             <td><input type="text" name="fvalue" 
                      size="5" maxsize="3">
             </td></tr>
                <br><input type="submit" name="Update" 
                           value="Update">
               </td></tr>
         </table>
</body></html>

AbsentMindedWelder fucked around with this message at 04:02 on Apr 2, 2010

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

dv6speed posted:

This is some code I found on the Internet and am trying to get it work. I've played with it a number of ways and can't make it work right. The problem I'm having is that the variable 'fvalue' doesn't seem to be making it where it needs to be.

I'm sure the problem is a simple one, but it has me stumped. I tried googling PHP variables with no success. My server is running Debian and has PHP5 installed on it.

code:
?php
/* Program: parallel.php
 * Desc:    Takes data from the form and sends it to the 
 *          parallel port program (lptout).
 *			Values should be given in hex (0 - ff)
 *          requires lptout placed in /usr/sbin/
 *          
 *	By Andrew Nickson ([url]www.re-mastered.co.uk[/url])
 */

?>

<?php

  switch (@$_GET['do'])                               
  {

    case "update":
	{
		echo ("<center><br>Data sent to parallel port (0x$fvalue)</br></center>");

		exec ("/usr/sbin/lptout 0x$fvalue");
		include("parallel.inc");
	}
	break;             

    default:                                             
        include("parallel.inc");
  }
?>
code:
<?php
/* Program: Parallel.inc
 * Desc:    Contains the form data for the parallel control
 *          This will call parallel.php.
 *         
 *	By Andrew Nickson 2005 ([url]www.re-mastered.co.uk[/url])
 */

?>

<html>
<head><title>Parallel Port Controller</title></head>
<body topmargin="0" leftmargin="0" marginheight="0"
      marginwidth="0">
         <center><form action="parallel.php?do=update" method="POST"> 
         <table border="0">
          <tr><td align=right><b>Value (HEX)</b></td>
             <td><input type="text" name="fvalue" 
                      size="5" maxsize="3">
             </td></tr>
                <br><input type="submit" name="Update" 
                           value="Update">
               </td></tr>
         </table>
</body></html>

Looks like parallel.php is expecting $fvalue to be part of global variables or something... although he uses $_GET properly for 'do'. $fvalue needs to be read in from $_POST.

So at the top of parallel.php, change it to this:

php:
<?
?php
/* Program: parallel.php
 * Desc:    Takes data from the form and sends it to the 
 *          parallel port program (lptout).
 *            Values should be given in hex (0 - ff)
 *          requires lptout placed in /usr/sbin/
 *          
 *    By Andrew Nickson ([url]www.re-mastered.co.uk[/url])
 */

?>

<?php

  switch (@$_GET['do'])                               
  {

    case "update":
    {
          $fvalue $_POST['fvalue']; // now it's assigned what was passed in POST.
          /// rest of code follows as-is
?>

AbsentMindedWelder
Mar 26, 2003

It must be the fumes.

Lumpy posted:

code:
$fvalue = $_POST['fvalue'];
Thanks! Worked perfectly.

I (thought) I had tried something like that as a result of my googling, but I guess I had put it in the wrong place or had the syntax off.

Tad Naff
Jul 8, 2004

I told you you'd be sorry buying an emoticon, but no, you were hung over. Well look at you now. It's not catching on at all!
:backtowork:

duz posted:

That's presentational, which is what CSS is for:

code:
[...]
#userdataForm label {
text-align:right;
width:125px;
display:block;
float:left;
white-space:nowrap;
}
Edit: I just noticed, this is the PHP thread. Why arn't we discussing this in the web design thread?

To continue derailing, I did this in a recent project but was never satisfied about making labels fixed-width, especially if they run over the allotted width. Also you can't do this trick which lets you have clickable labels without assigning everything an id:

code:
<label>Label: <input type="text" name="blarg" /></label>
\/\/ I thought it was kind of tidy, myself. Is
code:
<label for="fuckingIdIHaveToSupply">Label: </label><input id="fuckingIdIHaveToSupply" type="text" name="blarg" />
better somehow?

Tad Naff fucked around with this message at 06:11 on Apr 2, 2010

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

FeloniousDrunk posted:

To continue derailing, I did this in a recent project but was never satisfied about making labels fixed-width, especially if they run over the allotted width. Also you can't do this trick which lets you have clickable labels without assigning everything an id:

code:
<label>Label: <input type="text" name="blarg" /></label>

Ugly! Those should be siblings anyway.

hayden.
Sep 11, 2007

here's a goat on a pig or something
Anyone have suggestions on where to look for hiring someone to help with a few seemingly easy wordpress pages?

The basic premise is a blog with digg-like voting for articles. I'm trying to get this done:

http://wordpress.org/support/topic/345017

for both the main page and each category page, as well as the ability to filter it down by date (like digg: recent, 24 hours, 7 days, etc).

How much should I expect to pay to get this coded? It seems like the coding itself is done, just needs some tweaking.

hayden. fucked around with this message at 06:46 on Apr 2, 2010

spiritual bypass
Feb 19, 2008

Grimey Drawer

hayden. posted:

Anyone have suggestions on where to look for hiring someone to help with a few seemingly easy wordpress pages?

http://forums.somethingawful.com/showthread.php?threadid=3246449

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

PHP ctype_digit posted:

Return Values

Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise.

Changelog

Version Description
5.1.0 Before PHP 5.1.0, this function returned TRUE when text was an empty string.
What is going on in the heads of the people who wrote this? So before PHP 5.1.0 this function behaved as per its description, but from 5.1.0 onwards they changed it so that it behaves differently to its description?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Hammerite posted:

What is going on in the heads of the people who wrote this? So before PHP 5.1.0 this function behaved as per its description, but from 5.1.0 onwards they changed it so that it behaves differently to its description?

To me it sounds like in 5.1.0 onwards they fixed a bug where it would incorrectly return TRUE for an empty string..... :iiam:

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

Lumpy posted:

To me it sounds like in 5.1.0 onwards they fixed a bug where it would incorrectly return TRUE for an empty string..... :iiam:

The description says, "Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise." If there are no characters in the string, then certainly it is true that every character in the string is a digit.

epswing
Nov 4, 2003

Soiled Meat
Or as a university prof of mine put it, "'all the elephants in the room are pink' is a true statement".

Begby
Apr 7, 2005

Light saber? Check. Black boots? Check. Codpiece? Check. He's more machine than kid now.

epswing posted:

Or as a university prof of mine put it, "'all the elephants in the room are pink' is a true statement".

I was confused as to Hammerite's argument, but this actually makes sense and cleared it up for me.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Begby posted:

I was confused as to Hammerite's argument, but this actually makes sense and cleared it up for me.

This is why all documentation should be written by a law firm! Intent be damned!! :)

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

epswing posted:

Or as a university prof of mine put it, "'all the elephants in the room are pink' is a true statement".

Was this in a MACM class and was he Russian and awesome? I think I know who you're talking about.

epswing
Nov 4, 2003

Soiled Meat
Naw it was Charlie Rackoff, CS program at the University of Toronto. I guess it's a common phrase, because it does get the point across rather well.

Acer Pilot
Feb 17, 2007
put the 'the' in therapist

:dukedog:

epswing posted:

Naw it was Charlie Rackoff, CS program at the University of Toronto. I guess it's a common phrase, because it does get the point across rather well.

His wiki is both hilarious and awful. Also, greetings fellow Canadian goon :canada:

rotaryfun
Jun 30, 2008

you can be my wingman anytime
How horrible is my login process? Am I missing something that will clean it up or optimize it?

php:
<?php
    session_start();

    $usernamePost $_POST['username'];
    $passwordPost $_POST['password'];
    
    if ($usernamePost == '') {
        header("Location: fail.php?reason=username");
        exit;
    }
    
    //!!!!!!!!!!! Connect to DB!!!!!!!!!!!!!!!//
    $server"localhost"/* Address of database server */
    $user""/* Database username */
    $password""/* Database Password */
    $database"";

    $link MYSQL_CONNECT($server$user$password) or die ( "Server is unreachable. Contact IT at x256 with this error message.");
    MYSQL_SELECT_DB($database) or die ( "Database not existent. Contact IT at x256 with this error message.");
    //!!!!!!!!!!! END Connect to DB!!!!!!!!!!!!!!!//
    
    $nameQuery mysql_query("SELECT username, password FROM users WHERE username = '$usernamePost'");
    $pullInfo mysql_fetch_array($nameQuery);
    $usernameSQL $pullInfo['username'];
    
    if ($usernameSQL == '') {
        header("Location: fail.php?reason=baduser");
        exit;
    }
    
    $passwordSQL $pullInfo['password'];
    
    if($passwordPost == $passwordSQL) {
        $_SESSION['username'] = $usernamePost;
        header("Location: main.php");
        exit;
    } else 
    {
        header("Location: fail.php?reason=badpass");
    }

?>

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
You don't appear to be sanitising user input - what happens if someone submits as "Name" the string
code:
' OR 'x'='x
? You should read up about SQL injection.

Hammerite fucked around with this message at 14:49 on Apr 8, 2010

Sebbe
Feb 29, 2004

To follow up on that, a simple way to avoid SQL-injection is to use prepared statements, though that'd mean you'd either have to switch over to using PDO or MySQLi.

It's pretty simple to do and will save you a lot of grief when it comes to sanitizing input.

Adbot
ADBOT LOVES YOU

Peanut and the Gang
Aug 24, 2009

by exmarx
Use PDO, which will protect from sql injections (as long as you use it correctly).
Make a header file that does all the bootstrapping, such as starting the session and connecting to the db. Add require('header.inc.php') at the top of other files to load it.
What happens if two users have the same username?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply