SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Error 404: Life not found silver trophybronze trophy
    Join Date
    Dec 2007
    Location
    UK Nr Manchester
    Posts
    3,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need a PHP script to carry a parameter/ID through to a contact form

    I'm hoping this is an easy one for anyone knowledgable with PHP.

    I just need a simple script that will allow a user to click on a 'contact us for more info on this special offer' type link, pick up a parameter on a page to identify what that special offer is (a title tag maybe?) and carry that through to the contact form so that the user doesn't have to enter any info other than their own details etc.

    If anyone can point me in the right direction I'd appreciate it, thanks!

    Rich
    It's 530 people, but do you really get it?
    ImgWebDesign - Web design in Buxton, High Peak, Derbyshire UK.

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    Well, it would depend on how you generate your page? (or is this an email?)

  3. #3
    Error 404: Life not found silver trophybronze trophy
    Join Date
    Dec 2007
    Location
    UK Nr Manchester
    Posts
    3,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey, it's a page on a Joomla site. A regular HTML form using PHP, the script is 'simple script'

    Code:
    <?php
    
    // Simple Form Script
    // Copyright (C) 2005  Eric Zhang
    // This program is free software; you can redistribute it and/or
    // modify it under the terms of the GNU General Public License
    // as published by the Free Software Foundation; either version 2
    // of the License, or (at your option) any later version.
    //
    // Please send bugs/questions to erkzh@yahoo.com.
    
    //--------------------------Set these paramaters--------------------------
    
    
    $subject = 'Contact from xxxxxxxxxx website';                // Subject of email sent to you.
    $emailadd = 'xxxxxxxxxxx';        // Your email address. This is where the form information will be sent.
    $url = 'xxxxxxxxxxxxxx';               // Where to redirect after form is processed.
    $req = '1';                                  // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
    
    // --------------------------Do not edit below this line--------------------------
    $text = "Results from form:\n\n";       
    $space = '  ';
    $line = '
    ';
    foreach ($_POST as $key => $value)
    {
    	if ($req == '1')
    	{
    		if ($value == '')
    		{echo "$key is empty";die;}
    	}
    	$j = strlen($key);
    		if ($j >= 20)
    		{echo "Name of form element $key cannot be longer than 20 characters";die;}
    	$j = 20 - $j;
    		for ($i = 1; $i <= $j; $i++)
    		{$space .= ' ';}
    	$value = str_replace('\n', "$line", $value);
    	$conc = "{$key}:$space{$value}$line";
    	$text .= $conc;
    	$space = '  ';
    }
    mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    ?>
    I'm happy to use something else if required.
    It's 530 people, but do you really get it?
    ImgWebDesign - Web design in Buxton, High Peak, Derbyshire UK.

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    73 Post(s)
    Tagged
    0 Thread(s)
    mkay... so that page looks to be waiting for form input. So your link would have to pass it information.

    PHP Code:
    <form id='emailme' action='whateverthatpageyoulinkediscalled.php' method='post'>
    <
    input type='hidden' name='specialoffer' value='phpfillinblankhereblank'>
    <
    a href="#" onclick="document.getElementById('emailme').submit();">Click here to send us an email</a
    something like that.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •