Sunday, 15 September 2013

php - Sending user data over part 2 -



php - Sending user data over part 2 -

i seeking more advice on way handle this.

i have got 1 page links each admin fellow member when clicked takes display name over. on sec page form takes display names , populates subject field display name. need grab email address associated user utilize email address form on sec page gets sent script can send email address hard code it.

so page 1 is:

<?php $args1 = array( 'role' => 'committee', 'orderby' => 'user_nicename', 'order' => 'asc' ); $committee = get_users($args1); foreach ($committee $user) { echo ' <a href="../contact-form?displayname=' . $user->display_name . '"><b style="font-size:18px;"> <tr> <td style="padding: 10px;">' .$user->job_title .' - </td> <td style="padding: 10px;">' .$user->display_name .'</td> </tr></b></a><br><br>'; } ?>

page 2 is:

<?php $displayname = $_get['displayname'];?> <form role="form" method="post" action="../mailuser.php"> <div class="form-group"> <input type="hidden" name="displayname" value="<?php echo $displayname ?>"> <input type="text" name="hp" class="hp" value="" alt="if fill field out email not sent"> </div> <div class="form-group"> <label for="inputname">your name</label> <input type="name" class="form-control" id="inputname" placeholder="enter name" name="username"> </div> <div class="form-group"> <label for="inputemail">email address</label> <input type="email" class="form-control" id="inputemail" placeholder="you@example.com" name="emailfrom"> </div> <div class="form-group"> <label for="inputmsg">message</label> <textarea class="form-control" rows="8" id="inputmsg" placeholder="please begin typing message..." name="emailmessage"></textarea> </div> <button type="submit" class="btn btn-primary pull-right">send</button> </form>

and send script has email hard coded in as:

$mail->from = 'myemail@dummy.com';

so need variable depending on person clicked on in first place. needs sent both hard coded email , persons email associated them in wordpress user database.

based on our comment discussion, should able along lines of next on page two. sure right email_address, i'm not sure if that's how get_users returns email address or not.

<?php $displayname = $_get['displayname']; $args1 = array( 'role' => 'committee', 'orderby' => 'user_nicename', 'order' => 'asc' ); $committee = get_users($args1); $matchingemail = false; foreach ($committee $user) { if ( !$matchingemail && $user->display_name == $displayname ) { // great, found our match $matchingemail = $user->email_address; // don't know if email_address right, double check , modify if necessary } } if ( $matchingemail ) { // proceed if matching email address found ?> <form role="form" method="post" action="../mailuser.php"> <div class="form-group"> <input type="hidden" name="displayname" value="<?php echo $displayname; ?>"> <input type="hidden" name="matchingemail" value="<?php echo $matchingemail; ?>"> <input type="text" name="hp" class="hp" value="" alt="if fill field out email not sent"> </div> <div class="form-group"> <label for="inputname">your name</label> <input type="name" class="form-control" id="inputname" placeholder="enter name" name="username"> </div> <div class="form-group"> <label for="inputemail">email address</label> <input type="email" class="form-control" id="inputemail" placeholder="you@example.com" name="emailfrom"> </div> <div class="form-group"> <label for="inputmsg">message</label> <textarea class="form-control" rows="8" id="inputmsg" placeholder="please begin typing message..." name="emailmessage"></textarea> </div> <button type="submit" class="btn btn-primary pull-right">send</button> </form> <?php } else { ?> <p>something wrong, can't find email address! please seek again.</p> <?php } ?>

finally on page three, send email, can like:

<?php $mail->addaddress(stripslashes( $_post["matchingemail"] ) ); ?>

php wordpress forms

No comments:

Post a Comment