LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 10-16-2012, 12:13 PM   #1
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Rep: Reputation: 17
Submit Code with php


Hi,

I know this is linux forum. but I know I can get anser here only.

I am looking to redirect to another page when do I select the server and press go button in php.

my code is below.



<html>
<head>
<title>Dynamic Drop Down List</title>
</head>
<BODY bgcolor ="pink">
<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
Server List :
<select Server Name='serv'>
<option value="">--- Select ---</option>
<option value="server1">--- Self ---</option>
<option value="server2">--- Server2 ---</option>
<?
$select=$_POST ['serv'];
if($serv == self)
{
header('Location: /etc/cfg2html/node1.cluster.com.html');
exit;
}
?>
</select>
<input type="submit" name="Submit" value="Go" />
</form>
</body>
</html>
 
Old 10-16-2012, 02:36 PM   #2
valdinei
LQ Newbie
 
Registered: Jul 2012
Location: Brazil
Distribution: Ubuntu, Freebsd, CentOS
Posts: 17

Rep: Reputation: Disabled
Post

I think that's how

Code:
<html>
 <head>
 <title>Dynamic Drop Down List</title>
 </head>
 <BODY bgcolor ="pink">
 <form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF; ?>">
 Server List :
 <select Server Name='serv'>
 <option value="">--- Select ---</option>
 <option value="server1">--- Self ---</option>
 <option value="server2">--- Server2 ---</option>
 <?
 
 if( isset($_POST ['serv']) )
 {  
     $select=$_POST ['serv'];
 }
 if(isset($select))
 {
    if($select == self)
    {
        header('Location: /etc/cfg2html/node1.cluster.com.html');
    }else{
        header('Location:'.$select. ' ');
    }
 } 
 ?>
 </select>
 <input type="submit" name="Submit" value="Go" />
 </form>
 </body>
 </html>

Test
 
Old 10-17-2012, 11:10 AM   #3
deepak_message
Member
 
Registered: Oct 2007
Posts: 175

Original Poster
Rep: Reputation: 17
Thank you very much for for your help.

The code is working but it does not find page. however page is there.

[root@node1 cfg2html]# ls -ld /etc/cfg2html/node1.cluster.com.html
-rwxrwxrwx 1 root root 626580 Sep 26 01:24 /etc/cfg2html/node1.cluster.com.html


Please help.
 
Old 10-17-2012, 11:50 AM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,696

Rep: Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894Reputation: 5894
Have you tried searching the internet for PHP tutorials and examples?

Code:
if( isset($_POST ['serv']) )
 {  
     $select=$_POST ['serv'];
 }
 if(isset($select))
 {
    if($select == self)
    {
        header('Location: /etc/cfg2html/node1.cluster.com.html');
    }else{
        header('Location:'.$select. ' ');
    }
 } 
 ?>
The possible values that can be assigned to serv is defined by value= which you have defined as server1, server2 or "" therefore the if statement "$select == self" will never be true. I don't pretend to be a programmer and there could be some errors. I would place this at the top. I assume your web server is configured to serve pages from /etc/cfg2html/

Code:
<?php
 
 if( isset($_POST ['Submit']) && $_POST ['Submit']=="Go" )
 {  
     $select=$_POST ['serv'];
     if($select == "server1")
        header('Location: /etc/cfg2html/node1.cluster.com.html');
    if($select == "server2")
        header('Location: url_for_server2 ');
 } 
 ?>
I've also reported your thread to be moved to programming.

Last edited by michaelk; 10-17-2012 at 12:11 PM.
 
Old 10-17-2012, 04:02 PM   #5
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
  


Reply



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
PHP code, my form wont submit to sql database ice2112 Programming 3 07-20-2011 07:04 PM
php form submit code not working FirstBorn Programming 3 12-27-2008 07:08 AM
php post method paypal submit UMG:Chicken_Soüp Programming 2 02-03-2008 03:19 AM
PHP form takes forever to submit newuser455 Programming 3 06-09-2005 04:17 AM
Using PHP to submit a GET Locura Programming 2 03-12-2004 01:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:55 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration