Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Hi,

I've spent a lot of time lookin g through the forum for a solution, and at my code hoping to catch something silly.

I think CouchCMS is brilliant and am wanting to use it for my next project. I could easily work around the form
issue I am having, but would love to do it the Couch way.

Here's the code I have from going through the tutorial for contact.php. I have included the whole file in case there
is something other than in the form part that could be affecting it. The form part is colored for easier visibility if
that is where you want to focus. I am sorry that changing color partially in a BBCode code block didn't work.

------------------------ BEGIN c o n t a c t . p h p ------------------------
<?php require_once( 'couch/cms.php' ); ?>
<cms:template title="Contact Us" >
<cms:editable name='group_social' label='Social Profiles'
desc='Your accounts on social sites' type='group' />
<cms:editable name='twitter_id' label='Your Twitter ID' group='group_social' type='text' />
<cms:editable name='facebook_id' label='Your Facebook ID' group='group_social' type='text' />
<cms:editable name='stumbleupon_id' label='Your StumbleUpon ID' group='group_social' type='text' />
<cms:editable name='flickr_id' label='Your Flickr ID' group='group_social' type='text' />
<cms:editable name='delicious_id' label='Your Delicious ID' group='group_social' type='text' />
</cms:template>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Aurelius | Contact Us</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- Stylesheets -->
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/styles.css" />

<!-- Scripts -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript" src="js/contact.js"></script>
<!--[if IE 6]>
<script src="js/DD_belatedPNG_0.0.8a-min.js"></script>
<script>
/* EXAMPLE */
DD_belatedPNG.fix('.button');

/* string argument can be any CSS selector */
/* .png_bg example is unnecessary */
/* change it to what suits you! */
</script>
<![endif]-->
</head>

<body>

<div id="wrapper" class="container_12 clearfix">

<!-- Text Logo -->
<h1 id="logo" class="grid_4">Aurelius</h1>

<!-- Navigation Menu -->
<ul id="navigation" class="grid_8">
<li><a href="contact.html" class="current"><span class="meta">Get in touch</span><br />Contact Us</a></li>
<li><a href="blog.html"><span class="meta">Latest news</span><br />Blog</a></li>
<li><a href="portfolio.html"><span class="meta">Our latest work</span><br />Portfolio</a></li>
<li><a href="about.html"><span class="meta">Who are we?</span><br />About</a></li>
<li><a href="index.html"><span class="meta">Homepage</span><br />Home</a></li>
</ul>

<div class="hr grid_12 clearfix">&nbsp;</div>

<!-- Caption Line -->
<h2 class="grid_12 caption clearfix">Enjoyed looking at our work? Don't hesitate to <span>contact us</span>!</h2>

<div class="hr grid_12 clearfix">&nbsp;</div>

<!-- Column 1 / Content -->
<div class="grid_8">
<cms:editable name='contact_intro' label='Introductory Text'
type='richtext'>
<p>Put your intro. text here.</p>
</cms:editable>

<!-- Contact Form -->
<cms:form action='' method='post' id='contact_form'>
<h3>Contact Form</h3>
<div class="hr dotted clearfix">&nbsp;</div>
<ul>
<li class="clearfix">
<label for="name">Name</label>
<cms:input type='text' name='name' id='name' required='1' />
<div class="clear"></div>
<cms:if k_error_name>
<p id='name_error' class='error'>Insert a Name</p>
</cms:if>
</li>
<li class="clearfix">
<label for="email">Email Address</label>
<cms:input type='text' name='email' id='email' required='1' validator='email' />
<div class="clear"></div>
<cms:if k_error_email>
<p id='email_error' class='error'>Enter a valid email address</p>
</cms:if>
</li>
<li class="clearfix">
<label for="subject">Subject</label>
<cms:input type='text' name='subject' id='subject' required='1' />
<div class="clear"></div>
<cms:if k_error_subject>
<p id='subject_error' class='error'>Enter a message subject</p>
</cms:if>
</li>
<li class="clearfix">
<label for="message">Message</label>
<cms:input type='textarea' name='message' id='message' required='1' rows="30" cols="30">
</cms:input>
<div class="clear"></div>
<cms:if k_error_message>
<p id='message_error' class='error'>Enter a message</p>
</cms:if>
</li>
<li class="clearfix">

<cms:if k_success>
<p id='mail_success' class='success'>Thank you. I'll get back to you as soon as possible.</p>
<cms:send_mail from=k_email_from to=k_email_to subject='Contact Form Submission from foo.site.com' debug='1'>
<cms:show k_success />
</cms:send_mail>
</cms:if>
<cms:if k_error>
<p id='mail_fail' class='error'>Sorry, an error has occured. Please try again later.</p>
</cms:if>
<div id="button">
<input type='submit' id='send_message' class="button" value='Submit' />
</div>
</li>
</ul>
</cms:form>

</div>

<!-- Column 2 / Sidebar -->
<div class="grid_4 contact">

<!-- Adress and Phone Details -->
<cms:editable name='contact_details' label='Contact Details'
type='richtext' >
<h4>Address and Phone</h4>
<div class="hr dotted clearfix">&nbsp;</div>
<ul>
<li>
<strong>Your Company Name</strong><br />
1458 Sample Road, Redvalley<br />
City (State) H4Q 1J7<br />
Country<br /><br />
</li>
<li>USA - (888) 888-8888</li>
<li>Worldwide - (888) 888-8888</li>
</ul>

<!-- Email Addresses -->
<h4>Emails</h4>
<div class="hr dotted clearfix">&nbsp;</div>
<ul>
<li>General - <a href="mailto:info@yourcompany.com">info@yourcompany.com</a></li>
<li>Sales - <a href="mailto:sales@yourcompany.com">sales@yourcompany.com</a></li>
</ul>
</cms:editable>

<!-- Social Profile Links -->
<cms:capture into='social_profiles'>
<h4>Social Profiles</h4>
<div class="hr dotted clearfix">&nbsp;</div>
<ul>
<cms:if "<cms:not_empty twitter_id />">
<li class="float"><a href="<cms:show twitter_id />"><img alt="" src="images/twitter.png" title="Twitter" /></a></li>
<cms:set has_profile='1' 'global' />
</cms:if>

<cms:if "<cms:not_empty facebook_id />">
<li class="float"><a href="<cms:show facebook_id />"><img alt="" src="images/facebook.png" title="Facebook" /></a></li>
<cms:set has_profile='1' 'global' />
</cms:if>

<cms:if "<cms:not_empty stumbleupon_id />">
<li class="float"><a href="<cms:show stumbleupon_id />"><img alt="" src="images/stumbleupon.png" title="StumbleUpon" /></a></li>
<cms:set has_profile='1' 'global' />
</cms:if>

<cms:if "<cms:not_empty flickr_id />">
<li class="float"><a href="<cms:show flickr_id />"><img alt="" src="images/flickr.png" title="Flickr" /></a></li>
<cms:set has_profile='1' 'global' />
</cms:if>

<cms:if "<cms:not_empty delicious_id />">
<li class="float"><a href="<cms:show delicious_id />"><img alt="" src="images/delicious.png" title="Delicious" /></a></li>
<cms:set has_profile='1' 'global' />
</cms:if>
</ul>
</cms:capture>

<cms:if has_profile>
<cms:show social_profiles />
</cms:if>
</div>

<div class="hr grid_12 clearfix">&nbsp;</div>

<!-- Footer -->
<p class="grid_12 footer clearfix">
<span class="float"><b>&copy; Copyright</b> <a href="">QwibbleDesigns</a> - remove upon purchase.</span>
<a class="float right" href="#">top</a>
</p>

</div><!--end wrapper-->

</body>
</html>

<?php COUCH::invoke(); ?>
------------------------ END c o n t a c t . p h p ------------------------

I have debugged by testing the sending of email successfully in this template. As well as seen the CMS correctly send email for a forgotten password. I do see an error in my Nginx logs saying it can't find send_email.php, however, I can 't find any reference to send_email.php in the sources. He'res the log entry:
2014/12/14 23:04:59 [error] 15635#0: *725 FastCGI sent in stderr: "Unable to open primary script: /usr/share/nginx/www/send_email.php (No such file or directory)" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "POST /send_email.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "localhost", referrer: "http://localhost/contact.php"

I couldn't find an Nginx config file example for CouchCMS, but I am using a simple, possibly even the default, debian nginx config file. Here's the server entry:
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6

root /usr/share/nginx/www;
index index.php;

# Make site accessible from http://localhost/
server_name localhost;

autoindex off;

# rewrite to front controller as default rule
location / {
try_files $uri $uri/ /index.php?$args;
}



# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/www;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}


Any insights into what the issue might be are greatly appreciated.
Hi atenhotep :)

I presume the problem with the form is that it is not sending the email on successful submission.

You stated you have already tested sending out email form the template and it worked fine.
So let us concentrate on our form code to debug the issue.

The code supposed to send the email is -
Code: Select all
<cms:if k_success>
    <p id='mail_success' class='success'>Thank you. I'll get back to you as soon as possible.</p>
    <cms:send_mail from=k_email_from to=k_email_to subject='Contact Form Submission from foo.site.com' debug='1'>
        <cms:show k_success />
    </cms:send_mail>
</cms:if>

Let us remove all the variables that are needed for the code to run and see if it works -
1. Put in hardcoded values for email addresses and message being sent and
2. Move the cms:send_mail block to outside the cms:if k_success condition (so now everytime you access the template an email should be sent.

The code would look like
Code: Select all
<cms:form action='' method='post' id='contact_form'>
<h3>Contact Form</h3>

    <cms:send_mail from='you@site.com' to='you@site.com' subject='Contact Form Submission from foo.site.com' debug='1'>
        Testing email
    </cms:send_mail>

    ...
   
    ...

Please make sure that the 'from' address belongs to the sit'es domain as some servers refuse to send mail from other domains.

Test out the template and see if an email gets sent.

There is a 'debug' parameter set in the code so you should get a log.txt file in the site's root. Please see what it reports.

Let us know.

Thanks.
Sorry about a delayed response. :oops: I did not get the email notification I was expecting with your reply. I have been busy working away on the site, and will come back to this soon. I will need to get an actual working contact form on the contact page shortly. When I discovered that you gave us the source code for a working example of the tutorial, by the time I reached the end of it, I was less worried about not succeeding in following the tutorial directly myself. I knew I could figure it out from your working example. For a one/two man project, your documentation is excellent.

Once again, I appreciate your timely response :D , and apologize again for not appreciating it sooner.

FWIW: I think Couch is great! I love creating the CMS around the design, even compared to templating based themes for light CMS systems that are not that hard to roll your own theme.

Let's see if I get the email this time?
3 posts Page 1 of 1
cron