Viewing 2 replies - 1 through 2 (of 2 total)
  • Any update on this? I’ve been trying to find an answer for awhile.

    Thread Starter Jayasri Nagrale

    (@jayasrinagrale)

    Yeah, here is the php code that I used.

    This is the code that we add in the popup (as html)

    <form action="link-to-php-file" method="POST" accept-charset="utf-8">
    <table>
      <tr>
        <td>
    	<label for="name">Name</label>
    	<input type="text" name="name"/>
        </td>
        <td>
    	<label for="email">Email</label>
    	<input type="text" name="email"/>
        </td>
        <td>
    	<input type="submit" name="Subscribe" value="Subscribe"/>
        </td>
      <tr>
    </table></form>

    And here is the php file that you got to create and add it on the server.

    <?php
    	//--- You need to set these ---//
    	$your_installation_url = 'http://www.your-website.com'; //Your Sendy installation (without the trailing slash)
    	$list = 'list-id'; //Can be retrieved from "View all lists" page
    	$success_url = 'http://www.your-website.com.com'; //URL user will be redirected to if successfully subscribed
    	$fail_url = 'http://www.your-website.com'; //URL user will be redirected to if subscribing fails
    	//---------------------------------------------------------------------------//
    
    	//POST variables
    	$name = $_POST['name'];
    	$email = $_POST['email'];
    	$boolean = 'true';
    	//session_start();
    	$_SESSION['ref'] = $_SERVER['REQUEST_URI'];
    	echo($ref);
    	//Check fields
    	if($name=='' || $email=='')
    	{
    		echo 'Please fill in all fields.';
    		exit;
    	}
    
    	//Subscribe
    	$postdata = http_build_query(
    	    array(
    	    'name' => $name,
    	    'email' => $email,
    	    'list' => $list,
    	    'boolean' => 'true'
    	    )
    	);
    	$opts = array('http' => array('method'  => 'POST', 'header'  => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata));
    	$context  = stream_context_create($opts);
    	$result = file_get_contents($your_installation_url.'/subscribe', false, $context);
    
    	//check result and redirect
    	if($result)
    		{
    		header("Location: $ref");
    		}
    	else
    		//header("Location: $fail_url");
    ?>

    Hope this helps.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can this be used in a popup?’ is closed to new replies.