Good morning,

I have a problem to this site https://lsfdhelper.000webhostapp.com/helper.php

If I go on request and press two request, there will be two request. Also, If I press all of the, all request will show. How can I do a script so if I press on request, others request to hide?

Also, how can I clean the inputs after Submit button is pressed.

And the last question. Is it possible to do, for instance <div id="d13">....</div> in a special php named d13.php and call it when needed.

Thank you, I posted the code below.

DON'T get scared of the code, it's same code, repeating

<!DOCTYPE HTML>

<html>
<head>
<link rel="stylesheet" href="css.css">
<script type="text/javascript">
function aratadiv(id) {


           var divelement = document.getElementById(id);
        
           if(divelement.style.display == 'block')
              divelement.style.display = 'none';
           else
              divelement.style.display = 'block';
              
        
        }
        
        function arata(id) {
        document.getElementById(id).style.display = "block";
        }
        
 
        
		function reset(id){
		
		document.getElementById(id).reset(); 
		}
		

		
		       
        
        
        
    </script>
    <style>
        #pcr{
        display: none;
        }
        #fr{
        display: none;
        }
        #request{
        display: none;
        }
        .outputcode {
        display: none;
        }
        #navigare2{
        display: none;
        }
        #formular13{
        display: none;
        }
        #formular2{
        display: none;
        }
		#formular10{
        display: none;
        }
		#formular11{
		display: none;
		}
    </style>
</head>
<body>
    <?php
	
	ini_set('display_errors', 0);
    ini_set('display_startup_errors', 0);
    error_reporting(E_ALL);
        // define variables and set to empty values
        
        $name = $rank = $ri = $sn = $sf = $pfsf = $sfcn = $ai = $groupdefault1 = $forumname = $discorduserid = $discordname = $offduty = $reason = "";
        
         
        $name = $_POST["name"];
        $rank = $_POST["rank"];
        $sn = $_POST["sn"];
        $ri = $_POST["ri"];
        $sf = $_POST["sf"];
        $pfsf = $_POST["pfsf"];
        $sfcn = $_POST["sfcn"];
        $ai = $_POST["ai"];
		$reason = $_POST["reason"];
		$offduty = $_POST["offduty"];
		$discordname = $_POST["discordname"];
		$discorduserid = $_POST["discorduserid"];
		$forumname = $_POST["forumname"];
		$forumlink = $_POST["forumlink"];
		$groupdefault = $_POST["groupdefault"];
		$groupdefault1 = $_POST["groupdefault1"];
		

        ?>
    <div class="topnav">
        <a href="index.php"  ><img src="https://img.icons8.com/metro/26/000000/about.png" align="middle">Information</a>
        <a href="helper.php" class="active"><img src="https://img.icons8.com/metro/26/000000/clipboard.png" align="middle" >LSFD Helper</a>
		<a href="login.php"  style="float:right;"><img src="https://img.icons8.com/metro/26/000000/password.png" align="middle" >Login</a>
        <a href="help.php" style="float:right;"><img src="https://img.icons8.com/metro/26/000000/online-support.png" align="middle">Help</a>
    </div>
    <div>
        <img class="center"src="https://img.icons8.com/metro/130/000000/clipboard.png">
    </div>
    <div class="page">
        <div class="choosing-header">
            <center>
                <a class="actions" onclick="aratadiv('pcr');">Patient Care Report</a>  
                <a class="actions" onclick="aratadiv('fr');">Fire Report</a>  
                <a class="actions" class="meniu" onclick="aratadiv('navigare2');">Request</a> 
                <div id='navigare2'>
                    <center>
                        <a class = 'actions' onclick="aratadiv('d2'); aratadiv('formular2');hide('formular13')">Off-Duty Employment</a>
                        <a class = 'actions' onclick="aratadiv('d10'); aratadiv('formular10');">Discord Assignment</a>
                        <a class = 'actions' onclick="aratadiv('d11'); aratadiv('formular11')">LS-RP Forum Group Assignment</a>
                        <a class = 'actions' onclick="aratadiv('d12');">TeamSpeak 3 Assignment</a>
                        <a class = 'actions' onclick="aratadiv('d13'); aratadiv('formular13');">Double Faction Permission</a>
                        <a class = 'actions' onclick="aratadiv('d14');">Namechange</a>
                        <a class = 'actions' onclick="aratadiv('d15');">Major Corruption Request</a>
                    </center>
                </div>
            </center>
        </div>
        <div id="fr">
            <h1>ddsadsadadasdfasfa</h1>
        </div>
        <div id="d13">
            <script>
                if(document.getElementById('d13').style.display == 'block')
                {
                <?php
                    $ri = "#13 (Double Faction Permission)";
                    
                    ?>
                 
                
            </script>
            <div id ="formular13">
                <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
                    <div class='pl'>
                        <label>Employee Name:</label>
                        <input type="text" name="name" placeholder="Ex: John Doe" value="<?php echo $name;?>">
                        <label>Employee Rank:</label>
                        <input type="text" name="rank" placeholder="Ex: Firefighter I" value="<?php echo $rank;?>">
                        <label>Employee Service Number:</label>
                        <input type="text" name="sn" placeholder="Ex: 23956" value="<?php echo $sn;?>">
                    </div>
                    <div class="dl">
                        <label>Secondary Faction:</label>
                        <input type="text" name="sf" placeholder="Los Santos Police Department" value="<?php echo $sf;?>">
                        <label>Secondary Faction Character Name:</label>
                        <input type="text" name="sfcn" placeholder="Ex: John Doen" value="<?php echo $sfcn;?>">
                        <div class = "dl">     <label>Permission From Secondary Faction:</label>
                            <input type="text" name="pfsf" placeholder="Ex: Photo, Link" value="<?php echo $pfsf;?>">
                        </div>
                    </div>
                    <div class="tl">
                        <label>Additional Information:</label>
                        <input type="text" name="ai" placeholder="Ex: Information" value="<?php echo $ai;?>">
                    </div>
                    <center>  <input id ="submit" type="submit" class="imputonlick" name="submit" value="Submit" onclick='arata("arata");return false;'>
                        <input  type="submit" class="imputonlick" name="reload" value="Reload" onclick='arata();return true; '>
                    </center>
                </form>
            </div>
        
		<div class="outputcode" id='arata'>
        <b> <?php
            echo "Title: "; echo $ri;
            
            echo "<br>";
            echo "<br>";
            echo "<br>";
            echo "<br>";
            
            echo "[divbox=white][center][img]https://i.imgur.com/ujHmoAV.jpg[/img][/center]";
            echo '<br>';
            
            echo "[list=none] ";
            echo date("F d"), ", ", date("Y");
            echo "<br>";
            echo "Departmental Request:";
            echo "<br>";
            
            echo "[b][u]Purpose[/u][/b]";
            echo "<br>";
            echo " [list=none]";
            echo "<br>";
            echo " Upon submission of this official request document — in accordance with the Los Santos Fire Department administrative documentation procedure — (Chief) Fire Officers will thoroughly analyze the request by the employee and determine eligibility.";
            echo "<br>";
            echo "[/list]";
            echo "<br>";
            
            echo "[b][u]Details[/u][/b]";
            echo "<br>";
            echo "[list=none]";
            echo "[*] [b]EMPLOYEE NAME[/b]: ", $name;
                echo "<br>";
            echo "[*] [b]EMPLOYEE RANK[/b]: ", $rank; 
                echo "<br>";
            echo "[*] [b]EMPLOYEE SERVICE NUMBER[/b]: ", $sn ;
                echo "<br>";
            echo "[size=1].[/size]";
            echo "[*] [b]REQUEST ITEM[/b]: ", $ri    ; 
            echo "<br>";
            echo "[*] [b]SECONDARY FACTION[/b]: ", $sf ;
                echo "<br>";
            echo "[*] [b]SECONDARY FACTION CHARACTER NAME[/b]: ", $sfcn;
                echo "<br>";
            echo "[*] [b]PERMISSION FROM SECONDARY FACTION[/b]: ", $pfsf;
                echo "<br>";
            echo "[/list][list=none]";
            echo "<br>";
            echo "[*] [b]ADDITIONAL INFORMATION[/b]: ", $ai;
                echo "<br>";
            echo "[/list]";
            echo "<br>";
            echo "[/divbox]";
            
           
            ?>
		</div>
		</div>
		</div>
		</div>
		
	

        <div id="d2">
            <script>
                if(document.getElementById('d2').style.display == 'block')
                {
                <?php
                    $ri = "#2 (Off-Duty Employment)";
                    
                    ?>
                 
                
            </script>
            <div id ="formular2">
                <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
                    <div class='pl'>
                        <label>Employee Name:</label>
                        <input type="text" name="name" placeholder="Ex: John Doe" value="<?php echo $name;?>">
                        <label>Employee Rank:</label>
                        <input type="text" name="rank" placeholder="Ex: Firefighter I" value="<?php echo $rank;?>">
                        <label>Employee Service Number:</label>
                        <input type="text" name="sn" placeholder="Ex: 23956" value="<?php echo $sn;?>">
                    </div>
                    <div class="dl">
                        <label>Place Of Off-duty Eployment:</label>
                        <input type="text" name="offduty" placeholder="Los Santos Police Department" value="<?php echo $offduty;?>">
                        <label>Reason For Off-duty Employment:</label>
                        <input type="text" name="reason" placeholder="Ex: Reason" value="<?php echo $reason;?>">
                    </div>
                    <div class="tl">
                        <label>Additional Information:</label>
                        <input type="text" name="ai" placeholder="Ex: Information" value="<?php echo $ai;?>">
                    </div>
                    <center>  <input id ="submit" type="submit" class="imputonlick" name="submit" value="Submit" onclick="arata('arata2'); return false;">
                        <input  type="submit" class="imputonlick" name="reload" value="Reload" onclick="arata();return true; curata();">
                    </center>
                </form>
            </div>
			<div class="outputcode" id='arata2'>
            <b> <?php
            echo "Title: "; echo $ri;
            
            echo "<br>";
            echo "<br>";
            echo "<br>";
            echo "<br>";
            
            echo "[divbox=white][center][img]https://i.imgur.com/ujHmoAV.jpg[/img][/center]";
            echo '<br>';
            
            echo "[list=none] ";
            echo date("F d"), ", ", date("Y");
            echo "<br>";
            echo "Departmental Request:";
            echo "<br>";
            
            echo "[b][u]Purpose[/u][/b]";
            echo "<br>";
            echo " [list=none]";
            echo "<br>";
            echo " Upon submission of this official request document — in accordance with the Los Santos Fire Department administrative documentation procedure — (Chief) Fire Officers will thoroughly analyze the request by the employee and determine eligibility.";
            echo "<br>";
            echo "[/list]";
            echo "<br>";
            
            echo "[b][u]Details[/u][/b]";
            echo "<br>";
            echo "[list=none]";
            echo "[*] [b]EMPLOYEE NAME[/b]: ", $name;
                echo "<br>";
            echo "[*] [b]EMPLOYEE RANK[/b]: ", $rank; 
                echo "<br>";
            echo "[*] [b]EMPLOYEE SERVICE NUMBER[/b]: ", $sn ;
                echo "<br>";
            echo "[size=1].[/size]";
            echo "[*] [b]REQUEST ITEM[/b]: ", $ri    ; 
            echo "<br>";
            echo "[*] [b]PLACE OF OFF-DUTY EPLOYMENT[/b]: ", $offduty ;
                echo "<br>";
            echo "[*] [b]REASON FOR OFF-DUTY EMPLOYMENT:[/b]: ", $reason;
                echo "<br>";
            echo "[/list][list=none]";
            echo "<br>";
            echo "[*] [b]ADDITIONAL INFORMATION[/b]: ", $ai;
                echo "<br>";
            echo "[/list]";
            echo "<br>";
            echo "[/divbox]";
            
            
            ?>
            </div>
    </div>
        </div>
    </div>
    
	    <div id="d10">
            <script>
                if(document.getElementById('d10').style.display == 'block')
                {
                <?php
                    $ri = "#10 (Discord Assignment)";
                    
                    ?>
                 
                
            </script>
            <div id = "formular10">
                <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
                    <div class='pl'>
                        <label>Employee Name:</label>
                        <input type="text" name="name" placeholder="Ex: John Doe" value="<?php echo $name;?>">
                        <label>Employee Rank:</label>
                        <input type="text" name="rank" placeholder="Ex: Firefighter I" value="<?php echo $rank;?>">
                        <label>Employee Service Number:</label>
                        <input type="text" name="sn" placeholder="Ex: 23956" value="<?php echo $sn;?>">
                    </div>
                    <div class="dl">
                        <label>Discord Name:</label>
                        <input type="text" name="discordname" placeholder="JohnDoe#0000" value="<?php echo $discordname;?>">
                        <label>Discord User ID:</label>
                        <input type="text" name="discorduserid" placeholder="Ex: f7e3cyu2gri27831ecn87h13" value="<?php echo $discorduserid;?>">
                    </div>
                    <div class="tl">
                        <label>Additional Information:</label>
                        <input type="text" name="ai" placeholder="Ex: Information" value="<?php echo $ai;?>">
                    </div>
                    <center>  <input id ="submit" type="submit" class="imputonlick" name="submit" value="Submit" onclick="arata('arata10'); return false;">
                        <input  type="submit" class="imputonlick" name="reload" value="Reload" onclick="reset('formular10'); return true;">
                    </center>
                </form>
            </div>
			<div class="outputcode" id='arata10'>
            <b> <?php
            echo "Title: "; echo $ri;
            
            echo "<br>";
            echo "<br>";
            echo "<br>";
            echo "<br>";
            
            echo "[divbox=white][center][img]https://i.imgur.com/ujHmoAV.jpg[/img][/center]";
            echo '<br>';
            
            echo "[list=none] ";
            echo date("F d"), ", ", date("Y");
            echo "<br>";
            echo "Departmental Request:";
            echo "<br>";
            
            echo "[b][u]Purpose[/u][/b]";
            echo "<br>";
            echo " [list=none]";
            echo "<br>";
            echo " pon submission of this official request document — in accordance with the Los Santos Fire Department administrative documentation procedure — (Chief) Fire Officers will thoroughly analyze the request by the employee and determine eligibility.";
            echo "<br>";
            echo "[/list]";
            echo "<br>";
            
            echo "[b][u]Details[/u][/b]";
            echo "<br>";
            echo "[list=none]";
            echo "[*] [b]EMPLOYEE NAME[/b]: ", $name;
                echo "<br>";
            echo "[*] [b]EMPLOYEE RANK[/b]: ", $rank; 
                echo "<br>";
            echo "[*] [b]EMPLOYEE SERVICE NUMBER[/b]: ", $sn ;
                echo "<br>";
            echo "[size=1].[/size]";
            echo "[*] [b]REQUEST ITEM[/b]: ", $ri    ; 
            echo "<br>";
            echo "[*] [b]DISCORD NAME[/b]: ", $discordname ;
                echo "<br>";
            echo "[*] [b]DISCORD USER ID[/b]: ", $discorduserid;
                echo "<br>";
            echo "[/list][list=none]";
            echo "<br>";
            echo "[*] [b]ADDITIONAL INFORMATION[/b]: ", $ai;
                echo "<br>";
            echo "[/list]";
            echo "<br>";
            echo "[/divbox]";
            
            
            ?>
            </div>
    </div>
        </div>
    </div>
    
	
	<div id="d11">
            <script>
                if(document.getElementById('d11').style.display == 'block')
                {
                <?php
                    $ri = "#11 (LS-RP Forum Group Assignment)   ";
                    
                    ?>
                 
                
            </script>
            <div id = "formular11">
                <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
                    <div class='pl'>
                        <label>Employee Name:</label>
                        <input type="text" name="name" placeholder="Ex: John Doe" value="<?php echo $name;?>">
                        <label>Employee Rank:</label>
                        <input type="text" name="rank" placeholder="Ex: Firefighter I" value="<?php echo $rank;?>">
                        <label>Employee Service Number:</label>
                        <input type="text" name="sn" placeholder="Ex: 23956" value="<?php echo $sn;?>">
                    </div>
                    <div class="dl">
                        <label>LSRP Forum Username:</label>
                        <input type="text" name="forumname" placeholder="Shagy" value="<?php echo $forumname;?>">
                        <label>LSRP Forum Account Link:</label>
                        <input type="text" name="forumlink" placeholder="Ex: Link" value="<?php echo $forumlink;?>">
						<label>Group Default:</label>
                        <input type="checkbox" name="groupdefault" value="<?php  echo $groupdefault ;?>">
						<input type="checkbox" name="groupdefault1" value="<?php echo $groupdefault1;?>">
                    </div>
                    <div class="tl">
                        <label>Additional Information:</label>
                        <input type="text" name="ai" placeholder="Ex: Information" value="<?php echo $ai;?>">
                    </div>
                    <center>  <input id ="submit" type="submit" class="imputonlick" name="submit" value="Submit" onclick="arata('arata11'); return false;">
                        <input  type="submit" class="imputonlick" name="reload" value="Reload" onclick="reset('formular11'); return true;">
                    </center>
                </form>
            </div>
			<div class="outputcode" id='arata11'>
            <b> <?php
			
			if ($_POST['groupdefault'] == "<?php  echo $groupdefault ;?>")
				$groupdefault = "X";
			else
				$groupdefault1 = "X";
				
            echo "Title: "; echo $ri;
            
            echo "<br>";
            echo "<br>";
            echo "<br>";
            echo "<br>";
            
            echo "[divbox=white][center][img]https://i.imgur.com/ujHmoAV.jpg[/img][/center]";
            echo '<br>';
            
            echo "[list=none] ";
            echo date("F d"), ", ", date("Y");
            echo "<br>";
            echo "Departmental Request:";
            echo "<br>";
            
            echo "[b][u]Purpose[/u][/b]";
            echo "<br>";
            echo " [list=none]";
            echo "<br>";
            echo " pon submission of this official request document — in accordance with the Los Santos Fire Department administrative documentation procedure — (Chief) Fire Officers will thoroughly analyze the request by the employee and determine eligibility.";
            echo "<br>";
            echo "[/list]";
            echo "<br>";
            
            echo "[b][u]Details[/u][/b]";
            echo "<br>";
            echo "[list=none]";
            echo "[*] [b]EMPLOYEE NAME[/b]: ", $name;
                echo "<br>";
            echo "[*] [b]EMPLOYEE RANK[/b]: ", $rank; 
                echo "<br>";
            echo "[*] [b]EMPLOYEE SERVICE NUMBER[/b]: ", $sn ;
                echo "<br>";
            echo "[size=1].[/size]";
            echo "[*] [b]REQUEST ITEM[/b]: ", $ri    ; 
            echo "<br>";
            echo "[*] [b]LSRP FORUM USERNAME[/b]: ", $forumname ;
                echo "<br>";
            echo "[*] [b]LSRP FORUM ACCOUNT LINK[/b]: ", $forumlink;
                echo "<br>";
			echo "[*] [b]GROUP DEFAULT[/b]: [" ,$groupdefault ,"] Yes [",$groupdefault1 ,"] No ";
                echo "<br>";
            echo "[/list][list=none]";
            echo "<br>";
            echo "[*] [b]ADDITIONAL INFORMATION[/b]: ", $ai;
                echo "<br>";
            echo "[/list]";
            echo "<br>";
            echo "[/divbox]";
            
            
            ?>
            </div>
    </div>
        </div>
    </div>
    
</body>

</html>

I'm not entirely clear what you're asking for, but it sounds like you're trying to have multiple pages on one page. Can't you have more than one page?

Certainly, if you have

nightmarehd it's same code, repeating

then it's a good sign you're doing something wrong; doing things repetitively should be the computer's job, not the programmer's.

Weedpacket yes, I'm trying to have multiple pages on a big page. The problem is that i want to have just one page at time. If you press two pages from request, they will both open, i want just one. For instance if one is already open when pressing another button, that should close

    The simplest way of doing what you are asking is to include a page id/name parameter in the navigation links and have the server-side code produce and output just the content that corresponds to the submitted page id/name.

    Next, any post method form processing code should go above the start of the html document, and it should -
    1. Detect that a post method form was submitted before accessing any of the $_POST data.
    2. Trim all submitted data so that you can detect if all white space characters were entered.
    3. Use the submitted page id/name to control which set of form processing code gets executed.
    4. Validate all inputs before using them. You should store validation errors in an array. This array then serves as an error flag. If the array is empty, there are no errors. If the array is not empty, there are errors. To output the errors at the appropriate point in the html document, test and output the content of this array. If you have more than one form with just a few fields, you should dynamically validate the inputs, by defining an array of expected form fields, for each page id/name, in an array with attributes that define each validation step, then loop over this defining array and use general purpose code to perform the validation steps.
    5. If there are no validation errors, use the submitted form data. You can dynamically process the submitted data by expanding the defining array mentioned in the above step, so that you are not writing out bespoke code for each different form and each field in each form that only differs in the names of the data being operated on.

    Also, you are using bbocde tags in your html markup. If this is intentional, the output must be processed to operate on the tags before it is sent to the browser. You should not directly echo any of the output. The output should be built in a php variable, so that it can be supplied as input to a bbcode processor.

      Here's another point for when you actually implement this. When selecting among existing employees, you should have either a select/option menu or a type-a-head/auto-suggest field to let you select, rather than to enter, multiple pieces of information for the employee. The form should submit only the user id, which would be stored with the other form information to identify which employee the submitted data is related to.

        Write a Reply...