Jump to content

php display include problem

Recommended Posts

So i have these 2 forms.

<form method="post" enctype="multipart/form-data"><input type="submit" name="start" value="Start" /></form>


<form method="post" enctype="multipart/form-data"><input type="submit" name="stop" value="Stop" /></form>

now i need a script that when the start button in form no.1 is pressed the page refreshes and includes form no.2 with the stop button and than if the stop button is pressed it includes the start button. I tried to made this script.

if ($server['Online'] == 0)	 {		  echo "<meta http-equiv='refresh' content='0;url=start.php'>";	 }else	 {		  echo "<meta http-equiv='refresh' content='0;url=stop.php'>";	 }

but it is only including the forms, I would like to stay on the index.php and change the content in the div. The scripts needs to fit in the script below

<?php	    if(!empty($_SESSION['LoggedIn']) && !empty($_SESSION['Username']))			    {   include('db/get_data.php');					   //**SCRIPT HERE**//			    }	    elseif(!empty($_POST['username']) && !empty($_POST['password']))			    {					    $username = mysql_real_escape_string($_POST['username']);					    $password = md5(mysql_real_escape_string($_POST['password']));   					    $checklogin = mysql_query("SELECT * FROM users WHERE Username = '".$username."' AND Password = '".$password."'");   					    if(mysql_num_rows($checklogin) == 1)							    {									    $row = mysql_fetch_array($checklogin);									    $email = $row['Emailaddress'];									    $_SESSION['Username'] = $username;									    $_SESSION['Emailaddress'] = $email;									    $_SESSION['LoggedIn'] = 1;									    echo "<meta http-equiv='refresh' content='0;index.php'>";							    }					    else							    {									    echo "<h1>Error</h1>";									    echo "<p>Sorry, your account could not be found. Please <a href=\"index.php\">click here to try again</a>.</p>";							    }			    }	    else			    {?>					    <h1>Member Login</h1>					    <p>Please login below.</p>   					    <form method="post" action="index.php" name="loginform" id="loginform">							    <fieldset>									    <label for="username">Username:</label><input type="text" name="username" id="username" /><br />									    <label for="password">Password:</label><input type="password" name="password" id="password" /><br />									    <input type="submit" name="login" id="login" value="Login" />							    </fieldset>					    </form>   <?php			    }

any ideas on how i can do it? Thanks before hand

Edited by dmallia
Link to post
Share on other sites

Assuming, that's the way you want to do it, just code two forms in the file that's targeted by the action.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...