LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-13-2011, 09:55 AM   #1
Stuart07
LQ Newbie
 
Registered: May 2006
Location: Manchester, NH
Distribution: CentOS5.5
Posts: 13

Rep: Reputation: 0
HTML to PHP to EXPECT formatting issue


I'm new to PHP, so I may be missing something obvious or it could be something with the HTML. I wrote an expect script that tests user authentication against a RADIUS server. The username is an email address, including an @ sign. I recently wrote an HTML/PHP front end to allow others to input username/password into a form and then see the results when they hit submit.

Expect code that takes two args username, and password
Code:
expect "#"

send    "test aaa group radius [lindex $argv 0] [lindex $argv 1] new-code\r"

expect  "#"
This works fine as far as I can tell, the two input boxes pass the input to the php script
Code:
<html>
<head>
<title>Authentication Test</title>
</head>
<body>
<form method= "post" action= "authentication.php">
<font size = "5" color = "blue"><b><u>USER AUTHENTICATION TOOL</u></b></font><br /><br />
Username:
<input type="text" size="30" maxlength="50" name="unstring"/><br />
Password:
<input type="text" size="30" maxlength="50" name="pwstring"/><br /><br />

<input type="submit" value="submit" name="submit"/><br />
</form><br />
</body>
</html
>

This is the php
Code:
<?$uname = $_POST['unstring']?>

<?$passw = $_POST['pwstring']?>

<?$output = shell_exec("expect authentication1.exp {$uname} {$passw}")?>

<?echo "<pre>$output</pre>"?>
Every works as it's supposed to, except for the output of the script. When it displays on the webpage, it's segmented weirdly with  all throughout. What I've found is when I remove the @ sign in the username input, it fixes it.

Is there any part of HTML or PHP that treats the @ as a special character? 1 more thing is that I have another HTML/PHP/EXP script that works fine with the @.

Thanks
 
Old 04-16-2011, 06:53 AM   #2
carltm
Member
 
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 697

Rep: Reputation: 93
I'll bet that you'll need to use addslashes() or stripslashes()
which will handle the escaping of special characters.

I suspect the problem is in the assignment of $passw. Try this
and see if it works.

Code:
<?$passw = addslashes($_POST['pwstring'])?>
 
Old 04-18-2011, 03:46 PM   #3
Stuart07
LQ Newbie
 
Registered: May 2006
Location: Manchester, NH
Distribution: CentOS5.5
Posts: 13

Original Poster
Rep: Reputation: 0
I tried wrapping the addslashes and stripslashes tags around the POST variables, but it did not seem to fix the problem. I could have been applying them wrong.

I figured out another way display the results I was looking for, so to solve the strange coding problem I just had the expect script echo something if a regexp were true, instead of the expect script just echo'ing the direct router output.

Code:
send    "test aaa group radius [lindex $argv 0] [lindex $argv 1] new-code\r"

                expect  "#"

                set output $expect_out(buffer)

                set hostindex [lindex $output end]

                set hostname [string trim $hostindex "#"]

                if { [regexp -all "User rejected" $output] == "1" } {

                        puts "$hostname = User Rejected\n"

                } elseif { [regexp -all "User successfully authenticated" $output]  == "1" } {

                        puts "$hostname = User successfully authenticated\n"

                } else {

                        puts "$hostname = Unknown Condition\n"
                }
Cheers
 
  


Reply

Tags
expect, html, php, tcl


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script help with HTML formatting (??) cbtshare Programming 9 01-12-2010 10:09 AM
HTML Table Formatting Inbhir Pheofharain Programming 17 07-20-2009 03:02 PM
Adding users with PHP (pass php variables to Expect script) Jayla Programming 1 10-20-2006 10:44 AM
html formatting thunderbird sharky Linux - Software 4 01-17-2006 02:33 PM
Howto turn off html formatting in OpenOffice jlinkels Linux - Software 1 12-22-2005 01:56 PM


All times are GMT -5. The time now is 08:54 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration