Jump to content

clear variable PHP


believeinsharing

Recommended Posts

Hi All,

I am developing PHP website.

 

In my initial stage I wanted to accept some information from user... after that I wanted to display that information in different div but on same page...

 

Lets say My page is having two div tags. First div for simple HTML form which will help user to enter data, second div to display info entered by user.

I am doing this because I wanted to hide second div until user enter info into form and hit submit button.

 

Its working fine when page load first time. second div is hidden, user add info and hit submit button then second div comes with info added by user.

 

But when i refresh, its showing second div with previous info.

 

As I am new to php and javascript I am not sure what to do..

Let me knw if some have any idea to solve this,

Thanks in advance.

Link to comment
Share on other sites

My php file is:

 

<html>

<head><title>Create Coupons</title></head>

<body>

<div id="pageHeading">

Add following information to crate a coupon

</div>

<div id="couponForm">

<form name="couponInfo" method="post">

<table>

<tr><td>Enter coupon Heading:</td>

<td><input type="text" name="txtHeading"/>

</td></tr>

<tr>

<td>Enter coupon subheading:</td>

<td><input type="text" name="txtsubHeading"/></td>

</tr>

<tr>

<td>Enter detail:</td>

<td><input type="text" name="txtdetail"/></td>

</tr>

<tr>

<td>Enter validity date:</td>

<td><input type="text" name="txtDate"/></td>

</tr>

<tr>

<td>Select Image:</td>

<td><input type="file" name="couponImg" accept="image/gif, image/jpg, image/png"/></td>

</tr>

<tr>

<td colspan="2" align="center"><input type="submit" name="submit" value="Create Coupon" onclick="generateCoupon.js();"/> </td>

</tr>

</table>

</form>

</div>

 

<div id="couponSample">

 

<?php

$heading =$_POST["txtHeading"];

$subheading=$_POST["txtsubHeading"];

$detail=$_POST["txtdetail"];

$validthr=$_POST["txtDate"];

echo ($heading . "<br/>");

echo($subheading . "<br/>");

echo($detail . "<br/>");

echo($validthr . "<br/>");

?>

</div>

 

</body>

</html>

 

my Javascript code is:

 

function generateCoupon() {

{

var showdiv = document.getElementById("couponSample");

var frmdiv=document.getElementById("couponForm");

 

if(showdiv.style.display=="block")

{

showdiv.style.display="none";

frmdiv.innerHTML="show";

}

else

{

showdiv.style.display="block";

frmdiv.innerHTML="hide";

}

}

 

 

}

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.