Login | Register | FAQ
Anonymous

how to make Submit form with download link

+ Post a reply

9 posts Page 1 of 1


how to make Submit form with download link

by nepalithito » Tue Apr 10, 2012 10:04 am

Hi,

How to make submit form, that links to download a file. I mean after entering or submitting data in the form than go to download file link.
User avatar

nepalithito

  • Posts: 86
  • Joined: Thu Mar 01, 2012 10:10 am

Re: how to make Submit form with download link

by ChrisKweks » Tue Apr 10, 2012 4:18 pm

Hi nepalitheto, it is invariably a tricky thing to do when it comes to using data entry forms to redirect a user to a download page. What you'd do is to declare an 'if, var' javascript function telling the page to redirect to the download link only when the fields in the form are completed in an event where the ok or send button is clicked. Place the code handler on the button. You could choose to do an auto download after that button is clicked by creating an iframe and making its display source the file to be downloaded e.g <iframe src="download file.exe"></iframe>. If u still got problems, state them specifically.
User avatar

ChrisKweks

  • Posts: 2
  • Joined: Sun Oct 02, 2011 6:27 pm
  • Location: Lagos

Re: how to make Submit form with download link

by XainPro » Wed Apr 11, 2012 7:13 am

Simply in form action attribute put the download link or
in form action attribute just put the php file path and in php file check if user submit something then redirect them to download file path.
i.e
Code: Select all
<form action="thefile.php" method="post">
First Name:<input type="text" name="firstname" />
<br />
</form>


and thefile.php would look like this
Code: Select all
<?php
if(isset($_POST["firstname"]){
//code to save data in database
//and after that redirect user to original download link
header('Location: http://www.example.com/downloadlink');
}
?>

hope this will give you an idea how to do this its simple.
regards,
Xain Pro
User avatar

XainPro

  • Posts: 3662
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: how to make Submit form with download link

by nepalithito » Wed Apr 11, 2012 8:14 am

Hi,

Thank you for your inform.

I have created the form and where should I put the above code.


Code: Select all
<!---Begin form display-->
<form enctype="multipart/form-data" method="post" action="pgm-form_submit.php">
<style title="userform-inline_css">
/* Generated CSS theme for user-created form */

/* Hack to fix border on floated elements in IE */
.ie_cleardiv {
   display: block;
   clear: both;
   float: none;
   margin: 0;
   /*border: 1px dotted red;*/
}

.field-container {
   display: block;
   clear: both;
   margin-bottom: 6px;
   vertical-align: top;
   font-family: Trebuchet MS, arial, helvetica, sans-serif;
   /*border: 1px solid red;*/
}
.asterisk {
   color: red;
}

.instructions {
   margin-top: 0;
   color: #2e2e2e;
   font-family: Trebuchet MS, arial, helvetica, sans-serif;
   font-size: 12px;
   line-height: 1.1em !important;
}

.myform-field_title-top,
.myform-field_title-left {
   font-size: 11px;
   font-weight: normal;
   font-family: Trebuchet MS, arial, helvetica, sans-serif;
   margin-bottom: 0;
   color: #595959;
   border-width: 1px;
   border-color: #ccc;
   border-style: hidden;
}
.myform-field_title-left {
   display: block;
   float: left;
   margin-right: 15px;
   /*margin-top: 12px;*/
   margin-top: 2px;
   text-align: left;
   /*border: 1px solid red;*/
}

.myform-field_title-hidden {
   display: none;
}

.myform-input_container, .myform-formfield_container {
   display: block;
   float: left;
   margin-top: 0;
   font-size: 11px;
}

#form_body_container h1,
#form_body_container h2,
#form_body_container h3,
#form_body_container h4,
#form_body_container h5,
#form_body_container h6 {
   font-family: Trebuchet MS, arial, helvetica, sans-serif;
   margin-bottom: 0;
}
</style>
<!---Begin form display-->
<div id="form_body_container" style="text-align: left;background-color: transparent;margin: 10;padding: 0px;width: 210;border-style: none;border-width: 0;border-color: #000;">
<div class="field-container">
<h1 style="color: #595959;">Itinerary Reuest</h1>
<p class="instructions" style="color: #595959;">Please input relevant information to access the itinerary.u</p>
<div class="ie_cleardiv">
</div>

</div>
<div class="field-container">
<p class="myform-field_title-top" style="width: 75px;">First Name<span class="asterisk">*</span>
</p>
<p class="myform-input_container"><input type="text" name="First_Name" style="width: 200px;"/></p>
<div class="ie_cleardiv">
</div>
</div>
<div class="field-container">
<p class="myform-field_title-top" style="width: 75px;">Last Name<span class="asterisk">*</span>

</p>
<p class="myform-input_container"><input type="text" name="Last_Name" style="width: 200px;"/></p>
<div class="ie_cleardiv">
</div>
</div>
<div class="field-container">
<p class="myform-field_title-top" style="width: 75px;">Email Address<span class="asterisk">*</span>
</p>
<p class="myform-input_container"><input type="text" name="emailaddr" style="width: 200px;"/></p>
<div class="ie_cleardiv">

</div>
</div>
<input type="hidden" name="required_fields" value="First_Name;Last_Name;emailaddr;"/>
<div id="userform-submit_btn-container" style="text-align: center;">
  <input id="userform-submit_btn" type="submit" value="Submit &gt;&gt;" style="font-size: 13px;font-weight: normal;">
</div>

</form>

</div>


User avatar

nepalithito

  • Posts: 86
  • Joined: Thu Mar 01, 2012 10:10 am

Re: how to make Submit form with download link

by XainPro » Wed Apr 11, 2012 11:29 am

in this file
pgm-form_submit.php
User avatar

XainPro

  • Posts: 3662
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: how to make Submit form with download link

by nepalithito » Wed Apr 11, 2012 3:08 pm

I put your code in above file ?

I am trying to have a form in different pages. But when submitter click on button in different location will download different file.
User avatar

nepalithito

  • Posts: 86
  • Joined: Thu Mar 01, 2012 10:10 am

Re: how to make Submit form with download link

by XainPro » Thu Apr 12, 2012 4:00 am

you should add a field in the form and dynamically write its value of file name and in next page check that value and dynamically give option to download file for every page.
User avatar

XainPro

  • Posts: 3662
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: how to make Submit form with download link

by nepalithito » Thu Apr 12, 2012 5:29 am

Thank you for your mail. I am not sure where exactly and what code has to be placed. In the submit button or some where else.
User avatar

nepalithito

  • Posts: 86
  • Joined: Thu Mar 01, 2012 10:10 am

Re: how to make Submit form with download link

by XainPro » Thu Apr 12, 2012 9:09 am

You need some study please do study php tutorials and then try again :)
User avatar

XainPro

  • Posts: 3662
  • Joined: Fri Feb 17, 2012 8:10 pm


+ Post a reply

Page 1 of 1